我使用以下代码收集IP地址,但有时会发生输出$ ip为127.255.255.255。有人可以解释一下为什么会这样吗?
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
//Is it a proxy address
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip = ip2long($ip);
$ip = intval($ip);