Aaron Piotrowski (the guy who created the new Error-Exception system) has a great blog on this . I think the key point you need to understand is
In PHP 7, an exception will be thrown when a fatal and recoverable error ( E_ERROR
and E_RECOVERABLE_ERROR
) E_RECOVERABLE_ERROR
, rather than stopping the execution of the script. Fatal errors still exist for certain conditions, such as a lack of memory, and still behave as before, immediately terminating the script. An uncaught exception will also remain a fatal error in PHP 7. This means that if an exception arising from an error that was fatal in PHP 5.x is not implemented, it will still be a fatal error in PHP 7.
Note that other types of errors, such as warnings and notifications, remain unchanged in PHP 7. Only fatal and recoverable errors raise exceptions.
To say this, consider this
set_exception_handler()
is the function to handle Exception
by default (since PHP 7.0 this can handle all Throwable
s, so it can catch recoverable errors)set_error_handler()
- Function for handling recoverable errors
In other words, their functionality has not changed. Everything that runs them in PHP5 will call them in PHP7, it's simple, now you can use the try-catch
at the script level to handle a specific error.
source share