PHP – Get ip

June 4th, 2011

/*
* Return the real IP address
*/
function getRealIP() {
if ( isset($_SERVER[“REMOTE_ADDR”]) )    {
$myip = $_SERVER[“REMOTE_ADDR”] . ‘ ‘;
} else if ( isset($_SERVER[“HTTP_X_FORWARDED_FOR”]) )    {
$myip = $_SERVER[“HTTP_X_FORWARDED_FOR”] . ‘ ‘;
} else if ( isset($_SERVER[“HTTP_CLIENT_IP”]) )    {
$myip = $_SERVER[“HTTP_CLIENT_IP”] . ‘ ‘;
}
return $myip;
}

PHP, Program ,