Sometimes you don’t have a…

Sometimes you don’t have a debugger handy, but you have a function acting weird and you want to know where it’s being called. You can find out using the backtrace, like this –

echo debug_backtrace()[1]['function'];

And send that to /tmp/php-errors by using error_log.

error_log( "called by: " . debug_backtrace()[1]['function'] );
Advertisements