function GetIP () {
if (!empty ($_server["Http_x_forwarded_for")) {
$cip = $_server["Http_x_forwarded_for"];
}
ElseIf (!empty ($_server["Http_client_ip")) {
$cip = $_server["Http_client_ip"];
}
ElseIf (!empty ($_server["REMOTE_ADDR")) {
$cip = $_server["REMOTE_ADDR"];
}
else{
$CIP = "Cannot get!" ";
}
return $CIP;
}
echo GetIP ();
-----------------------------------------------------------------
function GetIP () {if (Isset ($_server[' http_x_forwarded_for ')) {$realip = $_server[' http_x_forwarded_for '];} elseif (i Sset ($_server[' http_client_ip ')) {$realip = $_server[' http_client_ip '];} else {$realip = $_server[' remote_addr '];} RE Turn $realip; }
Use $_server["REMOTE_ADDR" in PHP to obtain the IP address of the client, but if the client is accessed using a proxy server, the
is the IP address of the proxy server, not the true client IP address. To get the real IP address of the client through the proxy server, you need to use
$_server["Http_x_forwarded_for"] to read .
However, it is important to note that not every proxy server can use $_server["http_x_forwarded_for"] to read the client's real IP, some use this
The IP of the proxy server is still read by the method.
It is also important to note that if the client is not accessed through a proxy server , the value taken with $_server["Http_x_forwarded_for"] will
is empty .
HTTP_CLIENT_IP is the HTTP header sent by the proxy server. If "Super Anonymous proxy", the value of none is returned. Similarly, REMOTE_ADDR will be replaced with the IP of this proxy server.
REMOTE_ADDR is the IP of your client when it "shakes hands" with your server. If you use anonymous proxy, REMOTE_ADDR displays the IP of the proxy server.
Get an IP address in PHP