PHP error guide
PHP error_reporting hides warnings: meaning and fix
Error summary
Set an intentional error_reporting mask in the effective SAPI configuration and log errors even when production display is disabled.
What it means
Set an intentional error_reporting mask in the effective SAPI configuration and log errors even when production display is disabled.
What the error means
The current error_reporting bitmask excludes one or more diagnostic levels, so PHP does not report matching errors through its normal channel.
Why PHP produces it
A php.ini, pool, virtual-host, .user.ini, or runtime override changes the mask for the active SAPI.
PHP version notes
The behavior described for PHP error_reporting hides warnings applies to PHP 7.4–8.4 unless a narrower version is stated; exact wording can vary by SAPI and patch release.
Most common causes
- Production configuration uses E_ALL & ~E_NOTICE or another inherited mask.
- ini_set changes the mask after bootstrap.
- CLI and FPM load different configuration trees.
Minimal examples
BAD — reproduces the problem
error_reporting=0
display_errors=Off
log_errors=Off
FIXED — safer pattern
error_reporting=E_ALL
display_errors=Off
log_errors=On
Step-by-step diagnosis
- Print error_reporting() as both an integer and decoded constants in a safe diagnostic.
- Compare php --ini with phpinfo() from the affected web SAPI.
- Search pool and site overrides for error_reporting.
Fixes
Report all supported levels while controlling display separately
Use E_ALL and route logs to a protected destination.
error_reporting(E_ALL);
ini_set("display_errors", "0");
ini_set("log_errors", "1");
Common mistakes when fixing it
- Enabling display_errors on a public production site.
- Editing the CLI ini for an FPM problem.
- Using error_reporting(0) as an application fix.
How to prevent it
- Version-control site-specific PHP policy where possible.
- Expose effective configuration only to administrators.
- Monitor protected PHP error logs.
Web server / environment notes
cli, fpm, apache, shared-hosting. Each SAPI can have a different effective error mask.
Tags: cli,fpm,apache,shared-hosting