I am having an issue on my server (actually local host). I am working on a project which requires ip address of visitor but php $_SERVER['REMOTE_ADDR']
is returning always ::1
. I have also tried other functions like this one I found on web.
function getRealIpAddr(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
but this also returns the same thing. But I wanna get my external ip as I am the visitor at the time which should be 39.35.*.*
. Can anyone please explain, Is there anything wrong with my concepts.