xywuyiba7 发表于 2017-3-29 10:07:53

用php得到用户的ip

来自:
http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html


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;
}
页: [1]
查看完整版本: 用php得到用户的ip