Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
Created January 21, 2016 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplay-dk/d50205f38f1d0cf3744f to your computer and use it in GitHub Desktop.
Save mindplay-dk/d50205f38f1d0cf3744f to your computer and use it in GitHub Desktop.
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