Home >php教程 >php手册 >PHP代码:得到客户端的IP

PHP代码:得到客户端的IP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-21 09:00:021042browse
function get_client_ip()
{
if(getenv('HTTP_CLIENT_IP'))
{
  $client_ip = getenv('HTTP_CLIENT_IP');
}
elseif(getenv('HTTP_X_FORWARDED_FOR'))
{
  $client_ip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif(getenv('REMOTE_ADDR'))
{
  $client_ip = getenv('REMOTE_ADDR');
}
else
{
  $client_ip = $HTTP_SERVER_VAR['REMOTE_ADDR'];
}
  return $client_ip;
}



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