« Exception::__construct
Exception::getPrevious »

Exception::getMessage

(PHP 5, PHP 7, PHP 8)

Exception::getMessage — 例外メッセージを取得する

説明

final public function Exception::getMessage(): string

例外メッセージを返します。

パラメータ

この関数にはパラメータはありません。

戻り値

例外メッセージ文字列を返します。

例

例1 Exception::getMessage() の例

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

上の例の出力は、 たとえば以下のようになります。

Some error message

参考

関連キーワード:
Exception   メッセージ   getMessage   error message   construct   getPrevious   final   throw   catch   参考   Throwable
関連する関数・ページ:
throwable.getmessage   exception.construct   error.getmessage   yaf-exception.construct   class.yaf-exception   exception.tostring