© Mikael Olsson 2021
M. OlssonPHP 8 Quick Scripting Referencehttps://doi.org/10.1007/978-1-4842-6619-9_29

29. Error Handling

Mikael Olsson1  
(1)
Hammarland, Finland
 

An error is a mistake in the code that the developer needs to fix. When an error occurs in PHP, the default behavior is to display the error message in the browser. This message includes the file name, line number, and error description in order to help the developer correct the problem.

While compile and parse errors are typically easy to detect and fix, run-time errors can be harder to find because they may only occur in certain situations and for reasons beyond the developer’s control. Consider the following code that attempts to open a file for reading using the fopen function.
$handle ...

Get PHP 8 Quick Scripting Reference: A Pocket Guide to PHP Web Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.