« Error::getTraceAsString
Error::__clone »

Error::__toString

(PHP 7, PHP 8)

Error::__toString — エラーの文字列表現

説明

public function Error::__toString(): string

エラーの string 型の表現を返します

パラメータ

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

戻り値

エラーの string 型の表現を返します

例

例1 Error::__toString() の例

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

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

Error: Some error message in /home/bjori/tmp/ex.php:3
Stack trace:
#0 {main}

参考

関連キーワード:
表現   toString   error message   getTraceAsString   clone   throw   catch   home   bjori   Stack   trace   main   参考   Throwable
関連する関数・ページ:
exception.tostring   throwable.tostring   stringable.tostring   reflectionfunctionabstract.tostring   cachingiterator.tostring   reflectionconstant.tostring