Home  >  Article  >  Backend Development  >  Method code for obtaining client IP_PHP tutorial

Method code for obtaining client IP_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:44766browse

//
//获取客户端IP
//
function GetIP()
{
if(!empty($_SERVER["HTTP_CLIENT_IP"]))
$cip = $_SERVER["HTTP_CLIENT_IP"];
else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
$cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if(!empty($_SERVER["REMOTE_ADDR"]))
$cip = $_SERVER["REMOTE_ADDR"];
else
$cip = "无法获取!";
return $cip;
}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445107.htmlTechArticle// //获取客户端IP // function GetIP() { if(!empty($_SERVER[HTTP_CLIENT_IP])) $cip = $_SERVER[HTTP_CLIENT_IP]; else if(!empty($_SERVER[HTTP_X_FORWARDED_FOR])) $cip = $_SERVER[H...
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