Copy the Code code as follows:
function GetIP () {
$IP =getenv (' remote_addr ');
$IP _ = getenv (' http_x_forwarded_for ');
if ($IP _! = "") && ($IP _! = "Unknown")) $IP = $IP _;
return $IP;
}
Here's a better one.
Copy the Code code as follows:
function GetIP ()
{
if (Isset ($_server)) {
if (Isset ($_server[' http_x_forwarded_for ')) {
$realip = $_server[' http_x_forwarded_for ');
} elseif (Isset ($_server[' http_client_ip ')) {
$realip = $_server[' http_client_ip ');
} else {
$realip = $_server[' remote_addr ');
}
} else {
if (getenv ("Http_x_forwarded_for")) {
$realip = getenv ("Http_x_forwarded_for");
} elseif (getenv ("Http_client_ip")) {
$realip = getenv ("Http_client_ip");
} else {
$realip = getenv ("REMOTE_ADDR");
}
}
return $realip;
}
The above is introduced in PHP to obtain the client IP address function, including the content of the contents, I hope that the PHP tutorial interested in a friend helpful.