« Error::__construct
Error::getPrevious »

Error::getMessage

(PHP 7, PHP 8)

Error::getMessage — エラーメッセージを取得する

説明

final public function Error::getMessage(): string

エラーメッセージを返します。

パラメータ

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

戻り値

エラーメッセージを文字列で返します。

例

例1 Error::getMessage() の例

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

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

Some error message

参考

関連キーワード:
getMessage   エラーメッセージ   error message   construct   getPrevious   final   throw   catch   参考   Throwable   メッセージ
関連する関数・ページ:
exception.getmessage   throwable.getmessage   error.construct   function.ldap-err2str   function.ldap-error   function.radius-strerror