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

Fatal Errors vs Errors vs Warnings

PHP PHP 5.0+ Beginner
debt(d5/e3/b5/t7)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches' (d5). PHPStan can detect some error suppression patterns and missing error handlers, but the core issue—silent fatal errors in production due to display_errors=Off without logging—often requires runtime testing or production monitoring to catch. Not a simple linter check, but specialist tools can find some patterns.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix shows setting error_reporting(E_ALL) and using set_error_handler() to convert warnings/notices to exceptions. This is a straightforward configuration change plus adding a global error handler—not a one-liner but contained to a few files (bootstrap/config). Doesn't require cross-cutting refactors.

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

Closest to 'persistent productivity tax' (b5). Error handling strategy applies across all contexts (web, cli, queue-worker per applies_to) and affects every PHP file's behavior. Once you've established an error-silencing pattern or inconsistent error handling, it becomes a persistent drag—debugging becomes harder, monitoring becomes unreliable, and every developer must understand the current error handling setup.

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

Closest to 'serious trap' (t7). The misconception explicitly states developers believe fatal errors can be caught with try/catch, when in PHP 5 they cannot, and even in PHP 7+ true E_ERROR still terminates. This contradicts how exception handling works in most other languages where all errors are catchable. The Error/Exception distinction in PHP 7+ adds another layer of confusion for developers coming from other ecosystems.

About DEBT scoring →

Also Known As

E_ERROR E_WARNING E_NOTICE E_PARSE

TL;DR

PHP has three error levels that behave very differently: fatal errors halt execution, warnings continue but signal problems, and notices are advisory only.

Explanation

PHP's error system has multiple levels controlled by error_reporting(). Fatal errors (E_ERROR) stop execution immediately — you cannot catch them with try/catch, only with register_shutdown_function(). Parse errors (E_PARSE) prevent the file loading at all. Warnings (E_WARNING) continue execution but signal something wrong. Notices (E_NOTICE) are advisory — undefined variables, deprecated usages. PHP 7 replaced many engine-level fatals with catchable Error exceptions.

Common Misconception

Fatal errors can be caught with try/catch — they cannot in PHP 5; in PHP 7+ many are now catchable Error exceptions, but true E_ERROR still terminates the process.

Why It Matters

Understanding error levels determines how your error handler and monitoring behave — a swallowed notice today can be a production outage tomorrow.

Common Mistakes

  • Suppressing all errors with error_reporting(0) hiding real bugs
  • Not distinguishing Error exceptions (catchable) from true fatals (not catchable)
  • Logging warnings at same severity as fatals in monitoring

Code Examples

✗ Vulnerable
// Fatal errors were uncatchable in PHP 5:
require 'nonexistent.php'; // Fatal — script dies, no catch possible
call_to_undefined_function(); // Fatal
✓ Fixed
// PHP 7+: most fatals are now catchable Errors:
try {
    require 'nonexistent.php';
} catch (\Error $e) {
    echo 'Fatal caught: ' . $e->getMessage();
}

// Register shutdown for truly uncatchable fatals:
register_shutdown_function(function() {
    $error = error_get_last();
    if ($error && $error['type'] === E_ERROR) {
        error_log('Fatal: ' . $error['message']);
    }
});

Added 22 Mar 2026
Edited 23 Mar 2026
Views 55
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 2 pings F 4 pings S 4 pings S 0 pings M 2 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 1 ping T 1 ping F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W
No pings yet today
PetalBot 1
Scrapy 12 Amazonbot 7 Perplexity 5 Google 4 SEMrush 4 Ahrefs 3 Unknown AI 2 Claude 2 Bing 2 Meta AI 1 PetalBot 1
crawler 40 crawler_json 3
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Low
⚡ Quick Fix
Set error_reporting(E_ALL) in development and use set_error_handler() to convert warnings/notices to exceptions so nothing is silently swallowed
📦 Applies To
PHP 5.0+ web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
error_reporting(0) silencing all; no register_shutdown_function(); fatal error not visible because display_errors=Off with no logging
Auto-detectable: ✓ Yes phpstan lynis
⚠ Related Problems
🤖 AI Agent
Confidence: High False Positives: Low ✗ Manual fix Fix: Medium Context: File Tests: Update


✓ schema.org compliant