经测试代码如下:
/**
* 获得用户的真实ip函数
*
* @param
* @arrange (512.笔记) jb51.cc
**/
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
//to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
/*** 代码来自编程之家 jb51.cc(jb51.cc) ***/
原文链接:https://www.f2er.com/php/528854.html