I want to show the IP address of the computer's client. But in my computer which running in localhost show only "::1" . If i run in the localhost, it should be show 127.0.0.1. So how to show the IP address especially in IPv4. Because I read in another article that the ::1 is in IPv6. Here is my code :
function get_ip()
{
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;
}
$ip = get_ip();
echo $ip;
Give me help to fix this. Thank You.