Fatal Errors vs Errors vs Warnings
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']);
}
});
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
22 Mar 2026
Edited
23 Mar 2026
Views
26
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 7
Perplexity 5
Google 3
Unknown AI 2
SEMrush 1
Ahrefs 1
Also referenced
How they use it
crawler 18
crawler_json 1
Related categories
⚡
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
🔍 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