php 客户端IP

// 定义一个函数getIP()
function getIP()
{
global $ip;
if (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
else if(getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
else if(getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else $ip = "Unknow";
return $ip;
}

 

参考资料:

http://wenwen.soso.com/z/q416202671.htm

http://blog.csdn.net/lhjtianji/article/details/6931238

http://www.cnblogs.com/toby/archive/2011/10/08/2202014.html

你可能感兴趣的:(PHP)