Throwable
(PHP 7, PHP 8)
Introduction
Throwable is the base interface for any object that
can be thrown via a throw
statement, including
Error and Exception.
Note:
PHP classes cannot implement the Throwable interface directly, and must instead extend Exception.
Interface synopsis
Changelog
Version | Description |
---|---|
8.0.0 | Throwable implements Stringable now. |
Table of Contents
- Throwable::getMessage — Gets the message
- Throwable::getCode — Gets the exception code
- Throwable::getFile — Gets the file in which the object was created
- Throwable::getLine — Gets the line on which the object was instantiated
- Throwable::getTrace — Gets the stack trace
- Throwable::getTraceAsString — Gets the stack trace as a string
- Throwable::getPrevious — Returns the previous Throwable
- Throwable::__toString — Gets a string representation of the thrown object