Re: [PHP4BETA] How to get the name of a variable

From: Date: Sat, 08 Jan 2000 11:05:17 +0000
Subject: Re: [PHP4BETA] How to get the name of a variable
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-8986@lists.php.net to get a copy of this message
garyb@fxt.com wrote: > > 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?>"> <input type=="text" name="<? echo $bar?>" value="<?echo $$bar?>" size="<? echo $size?>"> > <? > } > > Then I could do this: > > <? > make_input ($foo,4); > make_input ($sam,92); > make_input ($toast); make_input("foo",4);, etc this could be easier :) > etc. > > And the name and value would both be taken from the single input variable. > > Is this possible in PHP3 or 4? > TIA, > G > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net -- mailto:hitower@don.sitek.net ==== ICQ 21050590 ==== Rostov-on-Don, Russia PGP fingerprint: 2E26 C4FF 6940 1F7E 0188 1684 7B21 CF13 068D AE82

« previous php.version4 (#8986) next »