Error Handling and Logging
Effective error handling and logging are essential parts of an application. Early versions of PHP lacked the support for exceptions and only used errors to flag faulty application states. The PHP 5 version brought forth the OOP features to the language and, with it, the exception model. This empowered PHP with the try...catch blocks like other programming languages. Later, the PHP 5.5 version brought support for the finally block, which always executed after the try...catch blocks, regardless of whether an exception was thrown or not.
Nowadays, the PHP language differentiates errors and exceptions as faulty states of an application. Both are raised as unexpected to our application logic. There are numerous types ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access