Home >Backend Development >PHP Tutorial >php gets the IP of the current user, php current user ip_PHP tutorial
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