PHP.nl

Errors in PHP 7

Errors in PHP 7

PHP 7 changes how most errors are reported by PHP. Instead of reporting errors through the traditional error reporting mechanism used by PHP 5, most errors are now reported by throwing exceptions. Error

As with normal exceptions, these exceptions will bubble up until they reach the first matching

block. If there are no matching blocks, then any default exception handler installed with will be called, and if there is no default exception handler, then the exception will be converted to a fatal error and will be handled like a traditional error. Errorcatchset_exception_handler

As the hierarchy does not inherit from , code that uses blocks to handle uncaught exceptions in PHP 5 will find that these s are not caught by these blocks. Either a block or a handler is required. Error``Exception``catch (Exception $e) { ... }``Error``catch (Error $e) { ... }``set_exception_handler

Error hierarchy

  • Throwable - Error - ArithmeticError - DivisionByZeroError - AssertionError - CompileError - ParseError - TypeError - ArgumentCountError - ValueError - UnhandledMatchError - FiberError - RequestParseBodyException - Exception - ...