note 45466 deleted from function.error-reporting by cmb
| From: | cmb@php.net | Date: | Sun, 08 Dec 2019 11:08:43 +0000 |
| Subject: | note 45466 deleted from function.error-reporting by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213438@lists.php.net to get a copy of this message | ||
Note Submitter: ferozzahid [at] usa [dot] com
----
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.