If I do print_r
in $GLOBALS I have all globals vars.
But I need something like this:
function foo() {
$a = 1;
$b = 2;
for($i = 0; $i < 10; $i++);
}
print_r(find_variables_in_function('foo')); // results: array(a => 1, b => 2, i => 10);
I'm trying implement a new feature in code.google.com/p/webgrind/ - since this tool give me functions in run time, I can generate a chart by variables size at end of all functions called.
$x = 2;
$y = 3;
function foo() {
$a = 1;
$b = 2;
for ($i = 0; $i < 10; $i++)
;
print_r(get_defined_vars()); // has no side effects - print null string
}