Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-12 08:51:32
Original
1111 people have browsed it

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>?>
Copy after login

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...
Related labels:
php
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template