We use the following function to auto detect if we are on a machine internally or on a live server and then choose the appropriate configs for various components:
Set an environment variable in your Apache virtual host configuration. This is the way the Zend Framework does it.
See the ZF quick start guide for an example (the "Create a Virtual Host" section.)
In your httpd.conf or a .htaccess file, put:
SetEnv APPLICATION_ENV "development"
Then in your application, use the getenv function to get the value:
$environment = getenv("APPLICATION_ENV");
if ($environment == "development")
{
// do development stuff
}
else if ($environment == "live")
{
// do live stuff
}