Search code examples
phpapacheip-addressipv6ipv4

REMOTE_ADDR and IPv6 in PHP


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

Thanks!


Solution

  • 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