Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
A Crash Course of Changes to Exception Handling in PHP 7
Nov 02, 2016 @ 16:10:09

The SitePoint PHP blog has a tutorial they've posted that shares information about changes in the exception handling in PHP 7 and what you need to know about them (and potentially change in your application).

Exception handling saves your code in the most unusual circumstances. PHP 7 has introduced two new classes that assist a developer in handling errors with ease, and that’s what we’ll look at in this post. Before the introduction of these classes in PHP 7, exception error classes were written to handle the different types of errors.

They start with the new "Throwable" interface that's the base for both the "Exception" and "Error" class types. From there the article talks about the "Error" type, showing the list of new errors included in PHP 7: ArithmeticErrors, TypeError, ParseError and AssertionError. It also includes code examples for each showing when they'd be thrown and how you can catch them (more specifically than just catching all exceptions).

tagged: changes exception handling php7 crashcourse

Link: https://www.sitepoint.com/a-crash-course-of-changes-to-exception-handling-in-php-7/


Trending Topics: