← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

PHP Error Levels & error_reporting

PHP OWASP A5:2021 PHP 5.0+ Intermediate
debt(d5/e3/b5/t7)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches it' (d5). The detection_hints list phpstan, phpcs, and semgrep — all specialist static analysis tools. The code_pattern (error_reporting(0) or @ suppression operator) is detectable by these tools but not by the compiler or a default linter, placing it squarely at d5.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix is essentially a one-liner (error_reporting(E_ALL) in dev), but fully correcting misuse involves also setting display_errors=Off and log_errors=On in php.ini or ini_set calls, and potentially adding set_error_handler(). That's a small coordinated fix within one config/bootstrap area, not a single-call swap, so e3 rather than e1.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). The choice applies to both web and cli contexts (wide applies_to scope) and affects every developer who must debug, upgrade, or monitor the application. Wrong error reporting silently hides deprecations and runtime notices, slowing many work streams (debugging, upgrades, security reviews), but it doesn't reshape the entire architecture — b5 fits well.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7). The misconception field states explicitly that 'setting error_reporting(0) is a valid security measure' — this is a widely-held wrong belief that contradicts how security actually works (hiding != preventing). Developers from other languages may also expect error suppression to be safe by default. This contradicts the principle seen in other ecosystems (e.g. exception-first languages) and is a documented, recurring pitfall, warranting t7.

About DEBT scoring →

Also Known As

PHP error reporting E_ALL E_NOTICE error_reporting()

TL;DR

PHP's graduated error severity system from E_NOTICE to E_ERROR, controlled by error_reporting and display_errors INI directives.

Explanation

PHP errors span multiple levels: E_ERROR (fatal, stops execution), E_WARNING (non-fatal runtime), E_NOTICE (minor runtime hints), E_DEPRECATED, E_STRICT (coding standards), E_PARSE (compile-time syntax), and the aggregate E_ALL. error_reporting = E_ALL is the correct development setting — it surfaces E_NOTICE and E_DEPRECATED issues that become real bugs. display_errors must be Off in production (log instead). set_error_handler() registers a custom handler to convert errors to exceptions or structured log entries. PHP 8.0 promotes many warnings to TypeErrors, making strict typing even more valuable.

Common Misconception

Setting error_reporting(0) in production is a valid security measure. Hiding errors does not prevent them — it makes debugging nearly impossible and can mask security-relevant failures. Log errors to a file with display_errors=Off and log_errors=On instead.

Why It Matters

PHP's error level bitmask controls which errors are reported and logged — running production with E_ALL hidden masks bugs; running development without E_DEPRECATED misses upgrade-breaking changes.

Common Mistakes

  • Setting error_reporting = 0 in development — hides all errors and makes debugging impossible.
  • Not enabling E_DEPRECATED — deprecated function calls are silent until the version that removes them.
  • Using display_errors = On in production — leaks file paths, stack traces, and database structure to users.
  • Not converting errors to exceptions with set_error_handler() — errors and exceptions get handled inconsistently.

Code Examples

✗ Vulnerable
# php.ini — production with errors displayed:
error_reporting = E_ALL
display_errors = On   ; Never in production — use log_errors = On instead
log_errors = Off      ; Errors not logged — invisible failures
✓ Fixed
; php.ini — development: show everything
error_reporting = E_ALL
display_errors = On
log_errors = On

; php.ini — production: log, never display
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log

// PHP — set at runtime (overrides php.ini)
error_reporting(E_ALL);
set_error_handler(function(int $errno, string $errstr, string $file, int $line): bool {
    if (!(error_reporting() & $errno)) return false; // respect @ operator
    throw new \ErrorException($errstr, 0, $errno, $file, $line);
});

// Convert all errors to exceptions — makes them catchable and loggable

Added 15 Mar 2026
Edited 22 Mar 2026
Views 70
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 2 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 6 pings F 3 pings S 3 pings S 2 pings M 3 pings T 0 pings W 0 pings T 1 ping F 2 pings S 1 ping S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 16 Perplexity 11 Amazonbot 9 SEMrush 5 Ahrefs 4 Google 4 Unknown AI 3 Bing 3 Claude 2 ChatGPT 1 Meta AI 1 PetalBot 1
crawler 56 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Low
⚡ Quick Fix
Set error_reporting(E_ALL) in development to see every notice and deprecation — these are bugs waiting to become errors in the next PHP version
📦 Applies To
PHP 5.0+ web cli
🔗 Prerequisites
🔍 Detection Hints
error_reporting(0) or E_ERROR only suppressing notices warnings; @ error suppression operator in code
Auto-detectable: ✓ Yes phpstan phpcs semgrep
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✓ Auto-fixable Fix: Low Context: File


✓ schema.org compliant