Home > php教程 > php手册 > php 获取当前用户的IP

php 获取当前用户的IP

WBOY
Release: 2016-05-30 16:59:45
Original
812 people have browsed it

代码如下:

<span style="color: #000000;">php
   </span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$_SERVER</span>['HTTP_CLIENT_IP'<span style="color: #000000;">]){
     </span><span style="color: #800080;">$onlineip</span>=<span style="color: #800080;">$_SERVER</span>['HTTP_CLIENT_IP'<span style="color: #000000;">];
}</span><span style="color: #0000ff;">elseif</span>(<span style="color: #800080;">$_SERVER</span>['HTTP_X_FORWARDED_FOR'<span style="color: #000000;">]){
     </span><span style="color: #800080;">$onlineip</span>=<span style="color: #800080;">$_SERVER</span>['HTTP_X_FORWARDED_FOR'<span style="color: #000000;">];
}</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{
     </span><span style="color: #800080;">$onlineip</span>=<span style="color: #800080;">$_SERVER</span>['REMOTE_ADDR'<span style="color: #000000;">];
}
</span><span style="color: #008000;">/*</span><span style="color: #008000;"> 何问起 hovertree.com </span><span style="color: #008000;">*/</span>

<span style="color: #0000ff;">echo</span> <span style="color: #800080;">$onlineip</span><span style="color: #000000;">;

</span>?>
Copy after login

推荐:http://www.cnblogs.com/roucheng/p/phpexcel.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template