PHP Conference Japan 2024

Exception::getMessage

(PHP 5, PHP 7, PHP 8)

Exception::getMessage取得例外訊息

說明

final public Exception::getMessage(): 字串

回傳例外訊息。

參數

此函式沒有參數。

回傳值

以字串形式回傳例外訊息。

範例

範例 #1 Exception::getMessage() 範例

<?php
try {
throw new
Exception("一些錯誤訊息");
} catch(
Exception $e) {
echo
$e->getMessage();
}
?>

上述範例將輸出類似以下的內容

Some error message

另請參閱

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top