PHP Debug_backtrace () function

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

  • 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.