I would like to find a user's IP address when he/she enters my page. How do I programmatically do that?
+10
A:
It should be contained in the $_SERVER['REMOTE_ADDR'] variable.
Kyle Cronin
2008-09-11 03:38:23
Since my own question has been closed (http://stackoverflow.com/questions/848091/how-can-i-get-the-users-ip-address-in-php) how can you get the above code to always find the IP address. Using this code, it will fall down to $_SERVER['REMOTE_ADDR'] and get a value of either blank or unknown in over 20% of cases.
Ryaner
2009-05-11 13:58:33
+4
A:
I always forget and do a:
var_dump($_SERVER);
and figure it out that way. Handy way to remember if you forget the exact key name.
SeanDowney
2008-09-11 06:15:43
+3
A:
echo "<PRE>" . print_r($_SERVER, true) . "</PRE>";
Is useful because it prints out the data in a nice pre-formatted manner which is easy to read on the browser.
Rushi
2008-09-11 08:41:27