Question
What is the difference between a fatal error and a warning in PHP?
Asked by: USER5418
66 Viewed
66 Answers
Responsive Ad After Question
Answer (66)
A fatal error (e.g., `E_ERROR`, `E_PARSE`) typically halts script execution immediately because the script cannot continue. A warning (e.g., `E_WARNING`, `E_NOTICE`) indicates a non-critical issue that doesn't stop execution but might lead to unexpected behavior or indicate a potential problem that should be fixed. Fatal errors are generally not catchable by `set_error_handler()` or `try-catch` blocks, while warnings often are.