Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

display PHP errors based on environment variable

<?php
 
if(!defined('ENVIRONMENT')){
    define('ENVIRONMENT', 'DEVELOPMENT');
}
 
if (defined('ENVIRONMENT')) {
 
    switch (ENVIRONMENT) {
        case 'DEVELOPMENT':
            ini_set('display_errors', 1);
            ini_set('display_startup_errors', 1);
            error_reporting(E_ALL|E_STRICT);
            break;
 
        case 'PRODUCTION':
            error_reporting(0);
            break;
 
        default:
            exit('The application environment is not set correctly.');
    }
}
Source by www.scratchcode.io #
 
PREVIOUS NEXT
Tagged: #display #PHP #errors #based #environment #variable
ADD COMMENT
Topic
Name
9+4 =