首頁  >  文章  >  後端開發  >  获取客户端IP的方法代码_PHP教程

获取客户端IP的方法代码_PHP教程

WBOY
WBOY原創
2016-07-20 11:05:44789瀏覽

//
//获取客户端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...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn