PHP Debugging Tool Debug_print_backtrace () function usage

Source: Internet
Author: User
Debug_print_backtrace () is a very low-key function, and few people notice it. But when I call another object on one object and then call the other object and one of the functions in the file goes wrong, it laughs.

What if we want to know who called a method? Debug_print_backtrace can solve
Debug_print_backtrace () can print out the calling process for a page, from where to where to go to a glance.
But this is a PHP5 proprietary function, fortunately in pear, it has been implemented,
Http://pear.php.net/package/PHP_Compat

Test the code with the following code:

<?php class a{function Say ($msg) {echo "msg:" $MSG; echo "<pre>";d ebug_print_backtrace (); }} Class B {function say ($msg) {$a = new A (); $a->say ($msg);}} Class C {function construct ($msg) {$b = new B (); $b->say ($msg); }} $c = new C ("test");

Output results

The code is as follows:

Msg:test #0 A->say (test) called at [/var/www/test/test0723.php:12] #1 b->say (test) called at [/var/www/test/ TEST0723.PHP:19] #2 c->construct (test) called at [/var/www/test/test0723.php:23]

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.