Exception::getMessage
(PHP 5, PHP 7, PHP 8)
Exception::getMessage — 獲取異常訊息內容
說明
final public Exception::getMessage(): string
返回異常訊息內容。
參數
此函式沒有參數。
返回值
返回字串型別的異常訊息內容。
範例
示例 #1 Exception::getMessage()示例
<?php
try {
throw new Exception("Some error message");
} catch(Exception $e) {
echo $e->getMessage();
}
?>
以上例程的輸出類似於:
Some error message