php8.5
Home/ Manual/ predefined / error/ Error::getMessage

Error::getMessage

PHP function Edit on GitHub ✎

(PHP 7, PHP 8)

Gets the error message

Description

Error::getMessage(): string

Returns the error message.

Parameters Parameters

Return Values

Returns the error message as a string.

Examples

Error::getMessage() example

php
<?php
try {
    throw new Error("Some error message");
} catch(Error $e) {
    echo $e->getMessage();
}
?>

The above example will output something similar to:

output
Some error message

See Also

  • Throwable::getMessage

Source: language/predefined/error/getmessage.xml · from the official PHP manual (php/doc-en)