Page 1 of 1

function backtrace possible?

Posted: Wed May 28, 2008 11:45 am
by jpschroeder
Hello,

Is it possible to traceback recent functions? For example in lets assume that I run function A, B, then C. In function C is there a way to find out that function A and B werre previously run without setting any variables during their execution? I'm familiar with __FUNCTION__ but that only gives the current function (I believe).

There is also debug_backtrace() but that seems to just list the magic variables, thus only listing the current function.

Thanks for any help!

Re: function backtrace possible?

Posted: Wed May 28, 2008 11:52 am
by jpschroeder
For anyone interested...

I somewhat solved the issue with debug_traceback(), but its quite rough. You receive an array full of information on previous functions that have been run.

To access previous functions you would use this format:

Code: Select all

 
$function = degub_backtrace();
$function[0]['function']     // The current function
$function[1]['function']     // Most recently executed function before this one
$function[2]['function']     // Second most recently executed function before this one etc...
 
If anyone has better information that would be awesome!