PHP Script to Show Visitor’s IP Address

Old Globe

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”]

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.