下面是可能返回的元素
登录后复制
line整数当前的行号
file字符串当前的文件名
object对象当前对象
type字符串当前的调用类型,可能的调用: 返回: “->” - 方法调用返回: “::” - 静态方法调用返回 nothing - 函数调用
args数组如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名

For Example one:

classHello{private$var;
        public$var2;
        protected$var3;

    publicfunction__construct($var,$var2,$var3){$this->var=$var;
            $this->var2=$var2;
            $this->var3=$var3;
        } 
   }


functiontest(Hello $hello){echo"Hi this is a test function"."
"
; print_r(debug_backtrace()); } $hello2=new Hello('A','B','C'); test($hello2);
登录后复制

实例One输出结果如下:

Hi this is a test function
Array ( [0] => Array (
[file] => D:\www\MyProjecttest\index4.php
[line] => 52
[function] => test
[args] => Array ( [0] => Hello Object ( [var:Hello:private] => A [var2] => B [var3:protected] => C ) ) ) )

For Example Two:

classHello{private$var;
        public$var2;
        protected$var3;

   publicfunction__construct($var,$var2,$var3)                   {$this->var=$var;
      $this->var2=$var2;
      $this->var3=$var3;
 } 

   functiontest(Hello $hello){echo"Hi this is a test function"."
"
; print_r(debug_backtrace()); } } $hello2=new Hello('A','B','C'); $hello2->test($hello2);
登录后复制

实例Two输出结果如下:

Hi this is a test function
Array ( [0] => Array (
[file] => D:\www\MyProjecttest\index4.php
[line] => 54
[function] => test
[class] => Hello
[object] => Hello Object ( [var:Hello:private] => A [var2] => B [var3:protected] => C )
[type] => ->
[args] => Array ( [0] => Hello Object ( [var:Hello:private] => A [var2] => B [var3:protected] => C ) ) ) )

版权声明:本文为博主原创文章,未经博主允许不得转载。

以上就介绍了PHP debug_backtrace 函数,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

09-16 07:29