function getRealIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
return $_SERVER['HTTP_X_FORWARDED_FOR'];
return $_SERVER['REMOTE_ADDR'];
}
echo getRealIP();
echo $_SERVER['REMOTE_ADDR'];
What is the problem with this code?
Because the result of it only stays like ::1
, I tried several times and only gives this result.