hex1a4 is correct.
$_SERVER['REMOTE_ADDR'] should work.
If you are testing it yourself, then it will, of course, show your IP address.
Make sure that you are using this within a script that is being requested by the client (user's browser) and not a script being initiated by the server.
$_SERVER['REMOTE_ADDR'] is the IP address of the entity running the script.