The PHP debug_backtrace () function generates a backtrace
the function returns an associative array .
Here are the elements that might be returned
Functions string Current function name
Line |
Integer |
The current line number |
File |
String |
The current file name |
Object |
Object |
Current Object |
Type |
String |
Current invocation type, possible invocation: return: "-"-Method call Returns: "::"-static method call returns Nothing-function call |
Args |
Array |
If the function parameter is listed in the function. If the referenced file name is listed in the referenced files |
For Example One:
Class hello{ private $var; Public $var 2; protected $var 3; Public function __construct ($var, $var 2, $var 3) { $this->var= $var; $this->var2= $var 2; $this->var3= $var 3; } } function test (Hello $hello) { echo "Hi This is a test function".
"; Print_r (Debug_backtrace ());} $hello 2=new Hello (' A ', ' B ', ' C '); Test ($hello 2);
The example one outputs the following results:
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))))
Note: Only four parameters are output here: File,line,function,args;
For Example:
Class hello{ private $var; Public $var 2; protected $var 3; Public function __construct ($var, $var 2, $var 3) { $this->var= $var; $this->var2= $var 2; $this->var3= $var 3; } function Test (Hello $hello) { echo "Hi This is a test function".
"; Print_r (Debug_backtrace ());} } $hello 2=new Hello (' A ', ' B ', ' C '); $hello 2->test ($hello 2);
The result of the example output is as follows:
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))))
Note: In this all parameters are output, respectively: File,line,function,class,object,type,args;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.