Error
The base class of PHP's internal errors.
Syntax
catch (Error $e) { … }Return value
ErrorAn object with the same methods as `Exception`.
Examples
Calling a function that does not exist:
<?php
try {
no_such_function();
} catch (Error $e) {
echo $e->getMessage();
}Output:
Call to undefined function no_such_function()Notes
Subclasses: TypeError, ValueError, ArithmeticError, DivisionByZeroError, ArgumentCountError. Such errors usually mean a bug in the code that should be fixed rather than worked around.
See also
In the tutorial
- Exceptions — Exceptions in PHP — throw, try, catch and finally, custom exception classes and built-in errors.