//Confirm Normal Global variables - If this is not done, get_defined_vars might not see them
foreach(array('_GET', '_POST', '_COOKIE', '_SERVER', '_ENV', '_FILES', '_REQUEST') as $NormalGlobals)
eval("return \$$NormalGlobals;");
unset($NormalGlobals);
//Parse all pre defined variables
$Output=ParseArrays(get_defined_vars(), 0);
print $Output; //Output the parsed information
function ParseArrays(&$NewArray, $Level) //Format array information and their values into a table. This is a recursive function that calls itself whenever a new array is found.
{
$Output=''; //This holds all the output for the current array
foreach($NewArray as $Name => $Value) //Loop through each value of the array
{
$Output.=''.htmlentities($Name, ENT_QUOTES, 'UTF-8').', '.htmlentities("$Value", ENT_QUOTES, 'UTF-8'); //Output the name and value
if($Name=="GLOBALS") //This variable likes to recurse, so do not treat it as an array by skipping it
$Output.=' [SKIPPED...]
';
else if(is_array($Value) && count($Value)) //If the value is a non empty array, parse the sub array
if($Level>20) //Skip if level is too high, preventing super recursion
$Output.=' [LEVEL TOO HIGH. SKIPPED...]
';
else
$Output.=''.ParseArrays($Value, $Level+1).'
';
else //Otherwise, a normal value just needs to break to a new line
$Output.='
';
}
return $Output;
}
?>
Dakusan's Default PHP Variables information