I'm writing a simple script for my webby that would send me an e-mail in case error 500 happens. I want to dump all possible variables, sessions, POSTs or whatever, present at time when error happened, so I can analyze the problem as precise as I can.
Here's the code I have for now:
function variable_name( &$var ) {
$var_name = array_search( $var, $GLOBALS );
return "{$var_name} = \"{$var}\"";
}
$bar = "whatever";
echo variable_name( $bar ); // bar = "whatever"
It's checking just $GLOBALS, but I need something that would check and print also $_POST, $_SESSION, class fields etc. I googled a bit and found just complicated functions that seem like an overkill for such easy task. Is there anything simple for this purpose or should I simply write a function for each of variable types?