Re: function for showing all currently set variables
| From: | Sebastian Delmont | Date: | Thu, 30 Nov 2000 17:00:33 +0000 |
| Subject: | Re: function for showing all currently set variables | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28078@lists.php.net to get a copy of this message | ||
phpinfo() will only show you php settings and apache variables...
you can use something like
reset( $GLOBALS );
while( list( $name, $val ) = each( $GLOBALS )) {
echo "$name: $val<BR>";
}
This will only show you global variables... it will not show local vars
inside a function (is there a $LOCALS array???).
I will show arrays as "array" and objects as "object"... You can use this
function if you want more information...
function DumpVariable( $var, $name = "" ) {
$type = gettype( $var );
echo "<TABLE BORDER=1 CELLSPACING=2><TR>\n";
echo " <TD VALIGN=TOP><B>$name:</B><BR>$type</TD>\n";
echo " <TD VALIGN=TOP>";
switch( $type ) {
case "array" :
case "object" :
reset( $var );
while( list( $key, $val ) = each( $var )) {
DumpVariable( $val, $key );
}
break;
case "boolean" :
case "integer" :
case "double" ;
case "string" :
case "resource" :
default :
echo $var;
break;
}
echo "</TD>\n";
echo "</TR></TABLE>\n";
}