獲取字串型別的異常追蹤資訊

Exception::getTraceAsString

(PHP 5, PHP 7, PHP 8)

Exception::getTraceAsString獲取字串型別的異常追蹤資訊

說明

final public Exception::getTraceAsString(): string

以字串型別返回異常追蹤資訊。

參數

此函式沒有參數。

返回值

以字串型別返回異常追蹤資訊。

範例

示例 #1 Exception::getTraceAsString()示例

<?php
function test() {
    throw new 
Exception;
}

try {
    
test();
} catch(
Exception $e) {
    echo 
$e->getTraceAsString();
}
?>

以上例程的輸出類似於:

#0 /home/bjori/tmp/ex.php(7): test()
#1 {main}

參見

Leave a Reply

Your email address will not be published. Required fields are marked *