List all variables
<?php
// create a few variables
$bar = 'foo';
$foo ='bar';
// create a new array object
$arrayObj = new ArrayObject(get_defined_vars());
// loop over the array object and echo variables and values
for($iterator = $arrayObj->getIterator(); $iterator->valid(); $iterator->next())
{
echo $iterator->key() . ' => ' . $iterator->current() . '<br />';
}
?>
Output....
GLOBALS => Array _ENV ==> Array HTTP_ENV_VARS => Array _POST => Array HTTP_POST_VARS => Array _GET => Array HTTP_GET_VARS => Array _COOKIE => Array HTTP_COOKIE_VARS => Array _SERVER => Array HTTP_SERVER_VARS => Array _FILES => Array HTTP_POST_FILES => Array _REQUEST => Array bar => foo foo => bar