How to get the name of a variable
| From: | garyb at fxt dot com | Date: | Sat, 08 Jan 2000 09:18:49 +0000 |
| Subject: | How to get the name of a variable | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-8984@lists.php.net to get a copy of this message | ||
Seems to me I used to know how to echo the name of a variable. I think it
would be useful in autogenerating forms. This is essentially the inverse of
the $$foo syntax, I think.
Let's say I have:
function make_input ($bar, $size=24) {
?>
<input type=="text" name="<? echo nameof($bar)?>"
value="<?echo
$bar?>" size="<? echo $size?>">
<?
}
Then I could do this:
<?
make_input ($foo,4);
make_input ($sam,92);
make_input ($toast);
etc.
And the name and value would both be taken from the single input variable.
Is this possible in PHP3 or 4?
TIA,
G