array debug_backtrace ( void );
它返回一个关联数组。可能返回的元素如下所示:-
function - 当前函数名。
line - 当前行号。
file - 当前文件名。
class - 当前类名。
object - 当前对象。
type - 当前通话类型。如果方法调用,则返回“->”。如果是静态方法调用,则返回“ ::”。如果调用函数,则不返回任何内容。
args - 如果在函数内部,则会列出函数参数。如果在包含文件中,则列出包含的文件名。
链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-debug-backtrace.html
来源:LearnFk无涯教程网
它返回描述中所述的关联数组。
<?php function printStr($str) { echo "Hi: $str"; var_dump(debug_backtrace()); } printStr('hello'); ?>
这将产生以下输出-
Hi: helloarray(1) { [0]=> array(4) { ["file"]=> string(36) "/var/www/learnfk/php/test.php" ["line"]=> int(8) ["function"]=> string(8) "printStr" ["args"]=> array(1) { [0]=> &string(6) "hello" } } }
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)