PHP Backtrace on Errors and Warnings

It is sometimes useful to see back-traces of PHP execution whenever errors or warnings appear on a page. Often you would insert var_dump() statements to see what is happening and to narrow down the source of a problem (I know, not the ideal way to fix bugs, but it is a technique that is always available, like vi on a *nix machine).

So this code will catch errors and warnings, and output a dump of the execution backtrace at that point. It’s not ideal, but it’s simple and it works:

https://gist.github.com/625769

No comments yet.

Leave a Reply