(PHP 7, PHP 8)
Error::getTrace — 取得堆疊追蹤
此函式沒有參數。
以 陣列 的形式回傳堆疊追蹤。
範例 #1 Error::getTrace() 範例
<?php
function test() {
throw new Error;
}
try {
test();
} catch(Error $e) {
var_dump($e->getTrace());
}
?>以上範例會輸出類似以下的內容:
array(1) {
[0]=>
array(4) {
["file"]=>
string(22) "/home/bjori/tmp/ex.php"
["line"]=>
int(7)
["function"]=>
string(4) "test"
["args"]=>
array(0) {
}
}
}