首頁 >後端開發 >php教程 >php 获取当前用户的IP,php当前用户ip_PHP教程

php 获取当前用户的IP,php当前用户ip_PHP教程

WBOY
WBOY原創
2016-07-12 08:51:321107瀏覽

php 获取当前用户的IP,php当前用户ip

代码如下:

<?<span>php
   </span><span>if</span>(<span>$_SERVER</span>['HTTP_CLIENT_IP'<span>]){
     </span><span>$onlineip</span>=<span>$_SERVER</span>['HTTP_CLIENT_IP'<span>];
}</span><span>elseif</span>(<span>$_SERVER</span>['HTTP_X_FORWARDED_FOR'<span>]){
     </span><span>$onlineip</span>=<span>$_SERVER</span>['HTTP_X_FORWARDED_FOR'<span>];
}</span><span>else</span><span>{
     </span><span>$onlineip</span>=<span>$_SERVER</span>['REMOTE_ADDR'<span>];
}
</span><span>/*</span><span> 何问起 hovertree.com </span><span>*/</span>

<span>echo</span> <span>$onlineip</span><span>;

</span>?>

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1130142.htmlTechArticlephp 获取当前用户的IP,php当前用户ip 代码如下: ? php if ( $_SERVER ['HTTP_CLIENT_IP' ]){ $onlineip = $_SERVER ['HTTP_CLIENT_IP' ];} elseif ( $_SERVER ['HTTP_X_FORW...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn