Exception + Error = Throwable Tree in PHP 7 over

Introduction

PHP 7.x introduces new Throwable interface together Error and Exception.

Interface Throwable
+-- Error
|   +-- ArithmeticError
|   |   +-- DivisionByZeroError
|   +-- AssertionError
|   +-- CompileError (PHP 7.3 over)
|       +-- ParseError
|   +-- TypeError
|       +-- ArgumentCountError
+-- Exception
    +-- ClosedGeneratorException
    +-- DOMException
    +-- ErrorException
    +-- IntlException
    +-- LogicException
    |   +-- BadFunctionCallException
    |   |   +-- BadMethodCallException
    |   +-- DomainException
    |   +-- InvalidArgumentException
    |   +-- LengthException
    |   +-- OutOfRangeException
    +-- PharException
    +-- ReflectionException
    +-- RuntimeException
        +-- mysqli_sql_exception
        +-- OutOfBoundsException
        +-- OverflowException
        +-- PDOException
        +-- RangeException
        +-- UnderflowException
        +-- UnexpectedValueException

Example & Output

ArithmeticError

DivisionByZeroError

AssertionError

ArgumentCountError

TypeError

Runtime Exceptions

Name
Example

LogicException

Last updated

Was this helpful?