array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'error.gettraceasstring.php', 1 => 'Error::getTraceAsString', 2 => 'Gets the stack trace as a string', ), 'up' => array ( 0 => 'class.error.php', 1 => 'Error', ), 'prev' => array ( 0 => 'error.gettrace.php', 1 => 'Error::getTrace', ), 'next' => array ( 0 => 'error.tostring.php', 1 => 'Error::__toString', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'language/predefined/error/gettraceasstring.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Error::getTraceAsString

(PHP 7, PHP 8)

Error::getTraceAsString获取字符串形式的调用栈(stack trace)

说明

final public Error::getTraceAsString(): string

以字符串形式返回 stack trace。

参数

此函数没有参数。

返回值

以字符串形式返回 stack trace。

示例

示例 #1 Error::getTraceAsString() 例子

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

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

以上示例的输出类似于:

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

参见