欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-05-16 23:40:46
...
//
//获取客户端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...