Exception::getMessage

(PHP 5, PHP 7, PHP 8)

Exception::getMessage獲取異常消息內(nèi)容

說明

final public Exception::getMessage(): string

返回異常消息內(nèi)容。

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

返回字符串類型的異常消息內(nèi)容。

范例

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

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

以上例程的輸出類似于:

Some error message

參見