REMOTE_ADDR and IPv6 in PHP

Alix Axel picture Alix Axel · Apr 12, 2010 · Viewed 11.6k times · Source

Is it safe to assume that $_SERVER['REMOTE_ADDR'] always returns a IPv4 address?

Thanks!

Answer

Michael Mrozek picture Michael Mrozek · Apr 12, 2010

The REMOTE_ADDR key is set by the web server, not PHP. If the web server listens on v6 and the user connects that way, it'll be a v6 address