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

From: Date: Sat, 08 Jan 2000 23:27:46 +0000
Subject: Re: [PHP4BETA] How to get the name of a variable
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-8991@lists.php.net to get a copy of this message
Max said, > 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. > > ... > > > <? > > make_input ($foo,4); > > make_input ($sam,92); > > make_input ($toast); > make_input("foo",4);, etc > > this could be easier :) This is a potential bug, besides being unaesthetic. Let's say I have $select->number("MyVariable",$selected,$start,$count,$gapbetween); rather than $select->number($MyVariable,$selected,$start,$count,$gapbetween); If I do a global search and replace on this variable name, using /$MyVariable/ because I have another variable named $NotMyVariable, the string is not matched and is left unchanged. Bad things invisibly ensue. Without contriving other examples (the above is a real one) it appears to me that this capability is symmetric with the $$ notation. This may seem esoterica, but I've bumped into a couple of different instances where I wished I had this - I just can't remember the others. Hey, Hochstaeder (sp?) showed self-reference is good! :O) ("Godel, Escher, Bach - the Eternal Golden Braid" - fun book) G

« previous php.version4 (#8991) next »