PHP debug_backtrace() 函数

来源:互联网 发布:mysql 反向建模 编辑:程序博客网 时间:2024/05/22 06:51

定义和用法

PHP debug_backtrace() 函数生成一个 backtrace。

该函数返回一个关联数组。下面是可能返回的元素:

名称类型描述function字符串当前的函数名。line整数当前的行号。file字符串当前的文件名。class字符串当前的类名object对象当前对象。type字符串当前的调用类型,可能的调用:
  • 返回: "->"  - 方法调用
  • 返回: "::"  - 静态方法调用
  • 返回 nothing - 函数调用
args数组如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名。

语法

debug_backtrace()

例子

<?phpfunction one($str1, $str2) { two("Glenn", "Quagmire"); }function two($str1, $str2) { three("Cleveland", "Brown"); }function three($str1, $str2) { print_r(debug_backtrace()); }one("Peter", "Griffin");?>

输出:

Array([0] => Array  ( [file] => C:/webfolder/test.php [line] => 7 [function] => three [args] => Array  (  [0] => Cleveland  [1] => Brown   )  )[1] => Array ( [file] => C:/webfolder/test.php [line] => 3 [function] => two [args] => Array  (  [0] => Glenn  [1] => Quagmire  ) ) [2] => Array ( [file] => C:/webfolder/test.php [line] => 14 [function] => one [args] => Array  (  [0] => Peter  [1] => Griffin  ) ))
原创粉丝点击