Is there a way to view the variables set in each stack frame in a backtrace? I can come pretty close with a combination of debug_backtrace(true)
to get the objects, get_object_vars
on each object to get $this vars, the args
key in each backtrace frame, and get_defined_vars
to get globals, but any temporary variables set within a function I can't find a way to retrieve.
Here's an example situation:
function method1($foo) {
$temp = method2($foo + 1);
foreach ($temp as $t) {
method2($t);
}
}
function method2($bar) {
$temp2 = $bar->value + $_GET['val'];
debug();
}
function debug() {
// to be created
$global_scope = get_defined_vars();
$bt = debug_backtrace(true);
}
I can get $foo
and $bar
via the args
key in the backtrace, the object variables of $bar
through get_object_vars
, and the globals through get_defined_vars
. I want to get the value of $temp2
and $temp
as well.
XDebug
not do what you need? Why re-invent a full blown debugger when installing one really really simple? – Thylacine