您好,欢迎访问一九零五行业门户网

PHP debug_backtrace 函数

php debug_backtrace() 函数生成一个 backtrace
该函数返回一个关联数组。
下面是可能返回的元素
function字符串当前的函数名
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){echohi 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 ) ) ) )
注:在此只输出四个参数,分别是:file,line,function,args;
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){echohi 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 ) ) ) )
注:在此所有参数都输出了,分别是:file,line,function,class,object,type,args;
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了php debug_backtrace 函数,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息