Moving from PHP 5 to PHP 7, a syntax error is no longer a fatal error, but an exception Throwablethat can be caught. However, some fatal errors, such as "Class not found," are still fatal in PHP 7. Why weren't all fatal errors converted to Throwable?
Example:
try {
include "file_with_syntax_error.php";
} catch (Throwable $ex) {
}
But
try {
include "file_with_namespace_error.php";
} catch (Throwable $ex) {
}
Edit : There is a comment from the error report https://bugs.php.net/bug.php?id=72089 :
As a rule, this has already been done for PHP 7.0.0, where it is reasonable and possible, see https://wiki.php.net/rfc/engine_exceptions_for_php7 .
source
share