note 84581 modified in language.variables by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 15:57:42 +0000 |
| Subject: | note 84581 modified in language.variables by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142142@lists.php.net to get a copy of this message | ||
[EDIT by danbrown AT php DOT net: The function provided by this author will give you all defined
variables at runtime. It was originally written by (john DOT t DOT gold AT gmail DOT com), but
contained some errors that were corrected in subsequent posts by (ned AT wgtech DOT com) and
(taliesin AT gmail DOT com).]
<?php
echo '<table border=1><tr> <th>variable</th> <th>value</th>
</tr>';
foreach( get_defined_vars() as $key => $value)
{
if (is_array ($value) )
{
echo '<tr><td>$'.$key .'</td><td>';
if ( sizeof($value)>0 )
{
echo '"<table border=1><tr> <th>key</th>
<th>value</th> </tr>';
foreach ($value as $skey => $svalue)
{
echo '<tr><td>[' . $skey
.']</td><td>"'. $svalue .'"</td></tr>';
}
echo '</table>"';
}
else
{
echo 'EMPTY';
}
echo '</td></tr>';
}
else
{
echo '<tr><td>$' . $key .'</td><td>"'.
$value .'"</td></tr>';
}
}
echo '</table>';
?>
--was--
[EDIT by danbrown AT php DOT net: The function provided by this author will give you all defined
variables at runtime.]
<?php
echo '<table border=1><tr> <th>variable</th> <th>value</th>
</tr>';
foreach( get_defined_vars() as $key => $value)
{
if (is_array ($value) )
{
echo '<tr><td>$'.$key .'</td><td>';
if ( sizeof($value)>0 )
{
echo '"<table border=1><tr> <th>key</th>
<th>value</th> </tr>';
foreach ($value as $skey => $svalue)
{
echo '<tr><td>[' . $skey
.']</td><td>"'. $svalue .'"</td></tr>';
}
echo '</table>"';
}
else
{
echo 'EMPTY';
}
echo '</td></tr>';
}
else
{
echo '<tr><td>$' . $key .'</td><td>"'.
$value .'"</td></tr>';
}
}
echo '</table>';
?>
http://php.net/manual/en/language.variables.php