即使在 php.ini 中停用了錯誤顯示,如何使持久的 PHP 通知保持沉默?

Barbara Streisand
發布: 2024-11-14 12:32:02
原創
497 人瀏覽過

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.

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

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板