tags:

views:

282

answers:

4

if the title seems too vague.. uhm i wanted to display every variable that i used to generate a page along with their variable names and values, is it possible and how?

    foreach($_SESSION as $varname => $value) {
        print "<b>".$varname."</b> = $value <br/>";
    }

^the above sample is what i use to display all session variables, what if i need to display the variables i set to display the page? are they registered also in some form of an array or should i also echo them individually?

A: 

you have to dump each variable individually.

var_dump($your_variable);
poh
+6  A: 

You can use get_defined_vars() which will give you an array of all variables declared in the scope that the function is called including globals like $_SESSION and $_GET. I would suggest printing it like so:

echo '<pre>' . print_r(get_defined_vars(), true) . '</pre>';
rojoca
had problems with formatting the results on how they get printed out but it seems i found a better solution from Josiah's answer below http://au.php.net/get_defined_vars#73608
lock
+6  A: 

The easiest way to do this is with get_defined_vars().

From the Documentation

This function returns a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables, within the scope that get_defined_vars() is called.

Producing a var_dump of this array will provide you with an extensive list.

var_dump( get_defined_vars() );
Josiah
A: 

A couple other interesting functions in the same area are get_defined_constants() and get_included_files()...

grantwparks