Instantly share code, notes, and snippets.

Embed
What would you like to do?
stack-traces

An example stack trace from PHP 7 without xdebug:

$ php -r "function foo() { throw new RuntimeException; } function bar() { foo(); } function baz() { bar(); } baz();"
PHP Fatal error:  Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
#2 Command line code(1): baz()
#3 {main}
  thrown in Command line code on line 1

Fatal error: Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
#2 Command line code(1): baz()
#3 {main}
  thrown in Command line code on line 1

And an example stack trace with xdebug:

$ php -r "function foo() { throw new RuntimeException; } function bar() { foo(); } function baz() { bar(); } baz();"
PHP Fatal error:  Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
#2 Command line code(1): baz()
#3 {main}
  thrown in Command line code on line 1

Fatal error: Uncaught RuntimeException in Command line code on line 1

RuntimeException:  in Command line code on line 1

Call Stack:
    0.0001     360720   1. {main}() Command line code:0
    0.0001     360720   2. baz() Command line code:1
    0.0001     360720   3. bar() Command line code:1
    0.0001     360720   4. foo() Command line code:1

In the latter case, we actually have two stack traces on screen at the same time, in opposing order - pretty confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment