PHP Error Types and Reporting
Understand notices, warnings, and fatal errors plus error_reporting levels.
PHP Error Types
PHP has several severity levels of errors:
- Notice — minor issue, execution continues
- Warning — non-fatal issue, execution continues
- Fatal Error — execution stops immediately
- Parse Error — syntax error, stops before execution
- Deprecated — feature will be removed
error_reporting()
Control which errors PHP reports with error_reporting():
<?php
// Show all errors (development)
error_reporting(E_ALL);
// Hide notices and deprecated
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
// Production: no display, log to file
error_reporting(E_ALL);
ini_set('display_errors', '0');
ini_set('log_errors', '1');
ini_set('error_log', '/var/log/php_errors.log');All lessons in this course
- PHP Error Types and Reporting
- Try, Catch, and Finally
- Creating Custom Exceptions
- Logging Errors and Best Practices