I am building an application and I have constant called ENVIRONMENT_SETTING
. As I am currently developing the application I have it as define('ENVIRONMENT_SETTING', 'dev');
Then I am checking at the top of the file what it is. I am currently doing if
statements like so:
if (defined('ENVIRONMENT_SETTING'))
{
if (ENVIRONMENT_SETTING == 'dev')
{
error_reporting(E_ALL);
}
elseif (ENVIRONMENT_SETTING == 'test' || ENVIRONMENT_SETTING == 'prod')
{
error_reporting(0);
}
}
else
{
die('Environment setting not set.');
}
This to me though seems like a bit too much code for such a simple check. Is there a better way to do this?