Home >Backend Development >PHP Tutorial >How can I silence persistent PHP notices even with error display disabled in php.ini?
Silencing PHP Notices
Despite disabling error display in php.ini, persistent notices such as "Constant DIR_FS_CATALOG already defined" persist. How can PHP be silenced from broadcasting these messages?
Addressing the Update
Even with display_errors set to Off, notices continue to appear. This is a known quirk in PHP 5.3. Additionally, excessive call stack reporting may be observed.
Disabling Notices
Notices can be suppressed by modifying the error reporting level to exclude the E_NOTICE flag, using either the error_reporting ini setting or the error_reporting() function.
Code:
// In php.ini error_reporting = E_ALL & ~E_NOTICE; // In PHP code error_reporting(E_ALL & ~E_NOTICE);
Caution
While silencing notices may alleviate the annoyance, it is essential to remember that notices often serve a purpose. Overriding a constant twice, as in the example provided, will result in an unchanged constant.
The above is the detailed content of How can I silence persistent PHP notices even with error display disabled in php.ini?. For more information, please follow other related articles on the PHP Chinese website!