Home > Backend Development > PHP Tutorial > How can I silence persistent PHP notices even with error display disabled in php.ini?

How can I silence persistent PHP notices even with error display disabled in php.ini?

Barbara Streisand
Release: 2024-11-14 12:32:02
Original
572 people have browsed it

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);
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template