Maison >développement back-end >tutoriel php >php 获取当前用户的IP,php当前用户ip_PHP教程

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

WBOY
WBOYoriginal
2016-07-12 08:51:321112parcourir

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...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn