PHP: function is_me()

A very useful function to determine first if the visitor is the developer or not and then act accordingly.


/* check if client is me */
function is_me()
if (($ip=="") and (strstr( $br, "Firefox")))
return true;
return false;

If the visitor’s IP is (=localhost) and the browser is “Firefox” then the visitor is me!

Usage example:

if (is_me()) { error_reporting( E_ALL); } else { error_reporting( 0); }

With the above snippet, one developer can check for errors and warnings in a running system without the casual visitor noticing a thing. It is very easy also to view the web-page with another browser to check what the visitor actually sees.

Visit The Light of the LAMP blog for more…