Facebook

Showing posts with label ip php visiter web site easy getenv remote addr. Show all posts
Showing posts with label ip php visiter web site easy getenv remote addr. Show all posts

Wednesday, January 4, 2012

Find your user's their IP address:


Show your user's their IP address:

Retrieving the user's IP address is actually much simpler than you might think, and can be done in a single line. Getenv("REMOTE_ADDR") will return the IP address of the person visiting your site. Generally this is accurate, however if the user is running through a proxie server, then it will return the address of the proxie.
In this example, we retrieve the user's IP and then simply echo it's value back to the user.
<?php
 //Gets the IP address
 $ip = getenv("REMOTE_ADDR") ;
 Echo "Your IP is " . $ip;
 ?>