note 45466 modified in function.error-reporting by danbrown

From: Date: Fri, 24 Oct 2008 18:40:16 +0000
Subject: note 45466 modified in function.error-reporting by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145711@lists.php.net to get a copy of this message
To be enable to switch between error_reporting during development and release phases, one can define say 'php_error_reporting' in the main configuration file (ini like file: no PHP) for the application as: # config.ini # PHP error reporting. supported values are given below. # 0 - Turn off all error reporting # 1 - Running errors # 2 - Running errors + notices # 3 - All errors except notices and warnings # 4 - All errors except notices # 5 - All errors php_error_reporting=4 # config.ini ends Setting error_reporting in PHP files would be something like the code below, assuming the function getinivar() returns the variable value from the configuration file. <?php // setting PHP error reporting switch(getinivar('php_error_reporting')) { case 0: error_reporting(0); break; case 1: error_reporting(E_ERROR | E_WARNING | E_PARSE); break; case 2: error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); break; case 3: error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); break; case 4: error_reporting(E_ALL ^ E_NOTICE); break; case 5: error_reporting(E_ALL); break; default: error_reporting(E_ALL); } ?> Feroz Zahid. --was-- To be enable to switch between error_reporting during development and release phases, one can define say 'php_error_reporting' in the main configuration file (ini like file: no PHP) for the application as: # config.ini # PHP error reporting. supported values are given below. # 0 - Turn off all error reporting # 1 - Running errors # 2 - Running errors + notices # 3 - All errors except notices and warnings # 4 - All errors except notices # 5 - All errors php_error_reporting=4 # config.ini ends Setting error_reporting in PHP files would be something like the code below, assuming the function getinivar() returns the variable value from the configuration file. [code] // setting PHP error reporting switch(getinivar('php_error_reporting')) { case 0: error_reporting(0); break; case 1: error_reporting(E_ERROR | E_WARNING | E_PARSE); break; case 2: error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); break; case 3: error_reporting(E_ALL ^ (E_NOTICE | E_WARNING)); break; case 4: error_reporting(E_ALL ^ E_NOTICE); break; case 5: error_reporting(E_ALL); break; default: error_reporting(E_ALL); } [/code] Feroz Zahid. http://php.net/manual/en/function.error-reporting.php

« previous php.notes (#145711) next »