Logging errors can be very helpful as your code base becomes huge. But sometime it’s still difficult to find out what’s calling the function that’s giving the error. Wouldn’t it be nice if there was a way to see how you’d got to that function?
Well of course there’s a way in PHP – debug_backtrace. Just add something similar in a suitable place in your code and you’ll be able to find what functions were called.
$trace=debug_backtrace(); $caller = $trace['function']; // or just dump all the info var_dump($trace);