Home  >  Article  >  Backend Development  >  php gets the IP of the current user, php current user ip_PHP tutorial

php gets the IP of the current user, php current user ip_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:51:321090browse

php gets the current user’s IP, php current user’s ip

The code is as follows:

<?<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>?>

Recommended: http://www.cnblogs.com/roucheng/p/phpexcel.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1130142.htmlTechArticlephp gets the IP of the current user, php the current user IP code is as follows: ? php if ( $_SERVER ['HTTP_CLIENT_IP' ]){ $onlineip = $_SERVER ['HTTP_CLIENT_IP' ];} elseif ( $_SERVER ['HTTP_X_FORW...
Statement:
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