Re: How to get name of a variable?

From: Date: Wed, 12 Jul 2000 16:48:03 +0000
Subject: Re: How to get name of a variable?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-6183@lists.php.net to get a copy of this message
Can list all get and post vars with: while(list($key,$value)=each($HTTP_GET_VARS)){ echo "$key<br>"; } and while(list($key,$value)=each($HTTP_POST_VARS)){ echo "$key<br>"; } Thomas Deliduka wrote: > I found it interesting that on 7/12/00 11:49 AM Bernhard Fuerst said: > > > is there any way to get the name of a variable? > > Just like gettype($var) returns the type of a variable I want to get the > > name of the variable. > > Hmmm, Well, if you have another variable which contains the name of another > variable, such as... > > you have a list of required fields in a form: > > name > addr > city > state > > and they're in an array $required > and you want to determine whether these fields are populated or not you can > do: > > if ($$required[0]) { echo "Missing Name"; } > > But I don't know how you can get the name of a variable otherwise. > -- > > Thomas Deliduka > IT Manager > ------------------------- > New Eve Media > The Solution To Your Internet Angst > http://www.neweve.com/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Bojan Gajic <bojan@inet.co.yu>

« previous php.general (#6183) next »