Exception::getMessage
PHP function
Edit on GitHub ✎
(PHP 5, PHP 7, PHP 8)
Gets the Exception message
Description
Exception::getMessage(): string
Returns the Exception message.
Parameters Parameters
Return Values
Returns the Exception message as a string.
Examples
Exception::getMessage() example
php
<?php
try {
throw new Exception("Some error message");
} catch(Exception $e) {
echo $e->getMessage();
}
?>The above example will output something similar to:
output
Some error messageSee Also
Throwable::getMessage