views:

338

answers:

1

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

Thanks!

+3  A: 

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

Michael Mrozek
+1, Thanks! I'm gonna try to figure out how I can convert an IPv6 address to a number.
Alix Axel
http://php.net/manual/en/function.inet-pton.php will convert v4 and v6 "string" addresses to their packed representation.
Marc B