Throw an exception and then output its message:
<?php
try {
throw new Exception("An error occurred");
} catch(Exception $e) {
echo $e->getMessage();
}
?>
Try it Yourself »
The getMessage()
method returns a description of the error or behaviour that caused the exception to be thrown.
$exception->getMessage()
Return Value: | Returns a string |
---|
Read more about Exceptions in our PHP Exceptions Chapter.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!