PHPdebug_backtrace () function
PHP debug_backtrace () function to generate a backtrace
This function returns an associated array..
The following elements may be returned:
Current function name of the function string
| Line |
Integer |
Current row number |
| File |
String |
Current file name |
| Object |
Object |
Current object |
| Type |
String |
The current call type. possible calls: return: "->"-return of method call: ":"-return of nothing-function call of static method call |
| Args |
Array |
If function parameters are listed. If the referenced file lists the referenced file names |
For Example one:
class Hello{ private $var; public $var2; protected $var3; public function __construct($var,$var2,$var3){ $this->var=$var; $this->var2=$var2; $this->var3=$var3; } }function test(Hello $hello){ echo "Hi this is a test function"."
"; print_r(debug_backtrace());}$hello2=new Hello('A','B','C');test($hello2);The output result of instance One is as follows:
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: file, line, function, and args;
For Example Two:
class Hello{ private $var; public $var2; protected $var3; public function __construct($var,$var2,$var3) { $this->var=$var; $this->var2=$var2; $this->var3=$var3; } function test(Hello $hello){ echo "Hi this is a test function"."
"; print_r(debug_backtrace()); }}$hello2=new Hello('A','B','C');$hello2->test($hello2);The Two output result of the instance 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: All parameters here are output: file, line, function, class, object, type, args;
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.