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:
Of course, if you have use virtual host locally like example.com then the function will be tricked.
Also if the host is not local but uses a widlcard or default vhost defn and the user adds the IP address to the hosts file locally.
I would recommend having a directory on the include path which also exists on live but is not replicated there - and simply store:
function getEnv(){
return 'Live';
}
or
function getEnv(){
return 'Test';
}
If both envs are on the same server - you can still do this by setting the include_path in Apache config or .htaccess.
This also allows you to seperate potentially sensitive env specific data - like database hosts/passwords and encyption keys.
C.