Identifying a development and production server by http_host I am using below code to recognize which set up I need to use in Codeigniter:

$dev_urls = array('dev.com');
$prod_urls = array('prod.com');

if(in_array($_SERVER['HTTP_HOST'], $dev_urls)){
    define('ENVIRONMENT', 'development');
}
else if(in_array($_SERVER['HTTP_HOST'], $prod_urls)){
    define('ENVIRONMENT', 'production');
}
else{
    define('ENVIRONMENT', '');
}


if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
    case 'development':
        error_reporting(E_ALL);
        require('/application/config/development/dev_config.php');
    break;

    case 'testing':
    case 'production':
        error_reporting(0);
        require('/application/config/production/prod_config.php');
    break;

    default:
        exit('The application environment is not set correctly.');
}
}


I went through this answer, but, I am still skeptical about my code.
Switching behaviour based on the Host header is not something I would recommend.  The environment should be a property of the server, rather than of the request.  Depending on your hosting situation (whether you have an IP-based virtual host or name-based virtual host, and the details of how your webserver is configured), you might even be able to hit code on the production server using a request with a forged (or missing) Host header.

I recommend that you identify the production environment by some other means — probably by some configuration file that exists on the production server.