PHPdebug_backtrace () function

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.