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.
以上是即使在 php.ini 中停用了錯誤顯示,如何使持久的 PHP 通知保持沉默?的詳細內容。更多資訊請關注PHP中文網其他相關文章!