Exception::__toString
(PHP 5, PHP 7, PHP 8)
Exception::__toString — 將異常對像轉換為字串
說明
public Exception::__toString(): string
返回轉換為字串(string)型別的異常。
參數
此函式沒有參數。
返回值
返回轉換為字串(string)型別的異常。
範例
示例 #1 Exception::__toString()示例
<?php
try {
throw new Exception("Some error message");
} catch(Exception $e) {
echo $e;
}
?>
以上例程的輸出類似於:
exception 'Exception' with message 'Some error message' in /home/bjori/tmp/ex.php:3 Stack trace: #0 {main}