PHP error guide
display_errors change does not show startup errors: meaning and fix
Error summary
Enable protected logging in configuration; do not rely on ini_set inside a script to reveal parse or startup failures that occur before it runs.
What it means
Enable protected logging in configuration; do not rely on ini_set inside a script to reveal parse or startup failures that occur before it runs.
What the error means
display_errors controls response display but cannot retroactively show errors raised before the code calling ini_set was parsed or executed.
Why PHP produces it
The directive remains disabled in effective configuration, or the failure occurs during startup/parse before runtime overrides execute.
PHP version notes
The behavior described for display_errors change does not show startup errors 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
- ini_set is placed in the file that has a parse error.
- A system-level setting cannot be changed at runtime.
- display is off and log_errors has no writable destination.
Minimal examples
BAD — reproduces the problem
ini_set("display_errors", "1")
this is invalid syntax
FIXED — safer pattern
display_errors=Off
log_errors=On
error_reporting=E_ALL
Step-by-step diagnosis
- Check directive access mode and effective value in the affected SAPI.
- Inspect web server, FPM, and PHP startup logs.
- Lint the file with the same PHP binary.
Fixes
Configure safe error logging before startup
Keep public display off in production and set a writable protected error log.
display_errors=Off
log_errors=On
error_reporting=E_ALL
error_log=/srv/app/var/php-error.log
Common mistakes when fixing it
- Exposing production traces in HTML.
- Assuming a blank page proves no error occurred.
- Making the log world-readable.
How to prevent it
- Configure logging before deployment.
- Lint source in CI.
- Monitor log write failures and disk space.
Web server / environment notes
fpm, apache, cli. Startup and parse diagnostics require configuration and server logs.
Tags: fpm,apache,cli