faqts : Computers : Programming : Languages : PHP : Common Problems : Tips and Tricks

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

14 of 15 people (93%) answered Yes
Recently 6 of 7 people (86%) answered Yes

Entry

How can I print a table of all the global variables in my PHP script?

Jun 30th, 1999 20:49
Nathan Wallace, Chris Lott


You can use something like the following to dump all the global
variables into a HTML table:

<TABLE CELLPADDING="5" BORDER="1">
<TR><TH ALIGN="LEFT">Variable</TH><TH ALIGN="LEFT">Value</TH></TR>
<?
    while (list($key, $value) = each($GLOBALS)) {
    if (strtolower($key) != "globals") {
      echo "<TR><TD><I>" . $key . "</I></TD><TD>$value";
        if (strlen($value) == 0) {
         echo "&nbsp;";
        } 
      echo "</TD></TR>\n";
     }
  }
?>
</TABLE>