PHP debug_print_backtrace() 函数

PHP Error 和 Logging 函数


Example

打印一条 PHP 回溯:

<?php
 function a($txt) {


 b("Glenn");
 }
 function b($txt) {


 c("Cleveland");
}
 function c($txt) {


 debug_print_backtrace();
 }
 a("Peter");
 ?>

以上代码的输出类似这样:

#0 c(Cleveland) called at [C:\webfolder\test.php:6]
 #1 b(Glenn) called at [C:\webfolder\test.php:3]
 #2 a(Peter) called at [C:\webfolder\test.php:11]

定义和用法

debug_print_backtrace() 函数打印 PHP 回溯(backtrace)。

debug_print_backtrace() 打印了一条 PHP 回溯。它打印了函数调用、被 included/required 的文件和 eval() 的代码。


语法

debug_print_backtrace(options,limit);
参数 描述
options

可选。规定以下参数的位掩码:

  • DEBUG_BACKTRACE_IGNORE_ARGS(是否忽略 "args" 的索引,包括所有的 function/method 的参数,能够节省内存开销。)
limit 可选。用于限制返回堆栈帧的数量。默认为 (limit=0) ,返回所有的堆栈帧。

技术细节

返回值: None
PHP 版本: 5.0+
PHP 更新日志:

PHP 5.4:添加了可选的参数 limit

PHP 5.3.6: 添加了可选的参数 options


PHP Error 和 Logging 函数

本教程仅供参考学习,如用于商业带来的问题,本站概不负责。
关注公众号
关注公众号

©2020 IT自习室京ICP备20010815号