I have a function
function my_dump($a,$name){
echo \'\'.$name.\":\\n\";
var_export($a);
echo \'
\';
}
How can
If it is a simple script, where all variables are defined in the global scope, you could get for the $GLOBALS solution:
function my_dump($a){
if(is_string($a) and isset($GLOBALS[$a])) {
echo "varname: $a\n";
$a=&$GLOBALS[$a];
}
echo ''.$name.":\n";
var_export($a);
echo '
';
}
this way you can call the dump function with the variable name instead
my_dump("cool_variable_name");
instead of
my_dump($cool_variable_name);