My recommendation would be to use an httpd environment variable.
This can act as a flag to inform your web application about the environment. Say you had a white label product, there it can be useful for example in setting what configuration should be used with a specific vhost.
<VirtualHost *:80>
DocumentRoot "/srv/www/foo/public"
ServerName foo.com
<Directory /srv/www/foo/public>
# production | development | staging
SetEnv APPLICATION_ENV development
...
And then in your PHP code you would access it like:
<?php
define('APPLICATION_ENV_LOCAL', 'local');
define('APPLICATION_ENV_DEVELOPMENT', 'development');
define('APPLICATION_ENV_STAGING', 'staging');
define('APPLICATION_ENV_PRODUCTION', 'production');
$app_env = (getenv('APPLICATION_ENV')) ? getenv('APPLICATION_ENV') : false;
if (empty($app_env) || ! in_array($app_env, array(APPLICATION_ENV_LOCAL, APPLICATION_ENV_DEVELOPMENT, APPLICATION_ENV_STAGING, APPLICATION_ENV_PRODUCTION))) {
throw new Exception("APPLICATION ENV IS NOT SPECIFIED OR IS INVALID.");
}
What I'd do is have totally separate config / INI type files that I include based on the environment. Those could determine error reporting behavior, maintain distinct database connections, anything else dependent on the application environment.