PHP debug_backtrace() 函数
实例
生成 PHP backtrace:
<?php
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>
亲自试一试 »
function a($txt) {
b("Glenn");
}
function b($txt) {
c("Cleveland");
}
function c($txt) {
var_dump(debug_backtrace());
}
a("Peter");
?>
定义和用法
debug_backtrace() 函数生成 backtrace(回溯跟踪)。
该函数显示由 debug_backtrace() 函数代码生成的数据。
返回一个关联数组。可能返回的元素如下:
| 名称 | 类型 | 描述 | 
|---|---|---|
| function | string | 当前函数名称 | 
| line | integer | 当前行号 | 
| file | string | 当前文件名 | 
| class | string | 当前类名 | 
| object | object | 当前对象 | 
| type | string | 
 当前调用类型。可能的调用: 
  | 
| args | array | 如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名。 | 
语法
 debug_backtrace(options, limit);
参数值
| 参数 | 描述 | 
|---|---|
| options | 
 可选。规定以下选项的位掩码: 
  | 
| limit | 可选。限制返回堆栈帧的数量。默认为 (limit=0) ,返回所有的堆栈帧。 | 
技术细节
| 返回值: | An array of associative arrays | 
|---|---|
| PHP 版本: | 4.3+ | 
| PHP 更新日志 | 
 PHP 5.4:添加了可选的参数 limit。 PHP 5.3.6:参数 provide_object 改成 options,并且增加了可选参数 DEBUG_BACKTRACE_IGNORE_ARGS。 PHP 5.2.5:添加了可选参数 provide_object。 PHP 5.1.1:添加了当前的 object 为可能返回的元素。  | 
PHP Error 错误参考手册
