Problem to find IP

1
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.

    
asked by anonymous 28.05.2018 / 03:17

1 answer

3

There is no error, it is returning the value of IPv6:

"The localhost name usually resolves to the IPv4 loopback address 127.0.0.1, and to the IPv6 loopback address :: 1."

Try to configure Apache properly.

    
28.05.2018 / 03:43