PHP Velho Oeste 2024

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

参考

add a note add a note

User Contributed Notes 1 note

up
0
ctymtce at 126 dot com
8 years ago
U can use get_class_methods($e) to view more methods.
To Top