PHP 教程 PHP 表单 PHP 高级教程 PHP 数据库 PHP XML PHP 与 AJAX PHP 参考手册

发布于 2016-11-18 14:38:03 | 66 次阅读 | 评论: 0 | 来源: 网络整理


定义和用法

debug_backtrace() 函数生成 backtrace。

该函数显示由 debug_backtrace() 函数代码生成的数据。

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

名称类型描述
functionstring当前的函数名。
lineinteger当前的行号。
filestring当前的文件名。
classstring当前的类名。
objectobject当前对象。
typestring当前的调用类型,可能的调用:
  • 返回:"->" - 方法调用
  • 返回:"::" - 静态方法调用
  • 返回 nothing - 函数调用
argsarray如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名。

语法

 debug_backtrace() 


实例

 <?php
 function 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:webfoldertest.php
 [line] => 7
 [function] => three
 [args] => Array
 (
 [0] => Cleveland
 [1] => Brown
 )
 )
 [1] => Array
 (
 [file] => C:webfoldertest.php
 [line] => 3
 [function] => two
 [args] => Array
 (
 [0] => Glenn
 [1] => Quagmire
 )
 )
 [2] => Array
 (
 [file] => C:webfoldertest.php
 [line] => 14
 [function] => one
 [args] => Array
 (
 [0] => Peter
 [1] => Griffin
 )
 )
 ) 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务