Tuesday, November 29, 2011

How to detect Visitor IP Address In PHP???

After a controversial incident, I have decided to look for IP address of my website's visitor. And what you know, there it is, a simple and short PHP script to do just that!!! Here it is:


// Example use of getenv() 
$ip getenv('REMOTE_ADDR');

// Or simply use a Superglobal ($_SERVER or $_ENV)

 $ip $_SERVER['REMOTE_ADDR'];

No comments: