PHP: query all variables defined inside function scope -
this out of curiosity, wondering if there way query variables defined inside scope of function (exclusively within scope, , within function) , put them in associative array. extended get_defined_vars
function.
the reason nice able save 'state' of execution @ point in program, instance debug, log, handle exceptions, or pass entire scope of function one. if i'm not mistaken, think get_object_vars
allows doing objects.
from comments of php.net
// top of php script $vars = get_defined_vars(); // stuff $foo = 'foo'; $bar = 'bar'; // variables defined in current scope $vars = array_diff(get_defined_vars(),$vars); echo '<pre>'; print_r($vars); echo '</pre>';
Comments
Post a Comment