PHP Script to Show Visitor’s IP Address

PHP Script to Show Visitor’s IP Address

PHP Script to Show Visitor’s IP Address

Sometimes you want to get the visitor’s IP address (e.g to show it to him or for logging purposes). This simple snippet does the job:

$ip = $_SERVER['REMOTE_ADDR'];

Also, if you have REGISTER_GLOBALS turned on on your server, you can use the shorter version:

$ip = @$REMOTE_ADDR;

Then you can easily use the variable called $ip for your needs.
[ad name=”In Post”]