In PHP, I’d like to get the details about a function call inside the function itself. The behavior I want (without doing this) is to have debug_backtrace() passed as an argument to the function.
I want that done automatically, for every call to a function.
I need this so I can have pre-defined errors for a fairly sizable project I’m working on, but I obviously want the line number of a central trigger_error() call, as that’s not very useful for tracking down the problem. I also don’t want to count on future developers to remember a debug_backtrace() argument.
You do realize that you can call
debug_backtrace()yourself, and it would be pretty much the same. For instance:If you
array_shiftthe given backtrace, if will be as if it were passed into the function.If you aren’t familiar with it:
Thus, because debug_backtrace() is numerically indexed, it will act the exact same.