You can also do that with perl. Here is an example of a short program that uses variables as labels: $label = "ONE"; goto $label; $label = "TWO"; goto $label; exit; ONE: print "1\n"; TWO: print "2\n"; Octavian ----- Original Message ----- From: "tribble" <lauraeaves@xxxxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Friday, August 08, 2008 11:54 AM Subject: Re: PHP - How Practical Is This? > That reminds me of the old snobol programming language which supported this > as well. In fact, it went a step further and allowed you to jump to a label > whose name was the value of a variable. Now that made for some interesting > code. > --le > > > ----- Original Message ----- > From: "Sina Bahram" <sbahram@xxxxxxxxx> > To: <programmingblind@xxxxxxxxxxxxx> > Sent: Thursday, August 07, 2008 10:20 PM > Subject: RE: PHP - How Practical Is This? > > > Wow, I had totally forgot about this. > > So basically, imagine if you wanted to dynamically choose a variable ... if, > let's say, the name of the variable, was itself a variable. > > Like this: > > $cat = 0; > $dog = 0; > $snake = 0; > > function incrementCountOfPets($pet) > { > $$pet++; > } > > > Now, if you passed the string "cat" into that function, the cat variable > would be incremented, but if you passed in the string "dog", the dog > variable would be incremented. > > If you didn't have this feature, you would be forced to using an if > statement or a switch/case statement block. > > It is truly mind boggling how many good design principles languages such as > php can allow one to break, *smile*. > > Take care, > Sina > > -----Original Message----- > From: programmingblind-bounce@xxxxxxxxxxxxx > [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of > james.homme@xxxxxxxxxxxx > Sent: Tuesday, August 05, 2008 7:35 AM > To: programmingblind@xxxxxxxxxxxxx > Subject: PHP - How Practical Is This? > > > Hi, > I don't understand how this works, so I don't know how important or > practical it is. This is some text from a PHP book I'm reading. > > Variable Variables > > On occasion, you may want to use a variable whose content can be treated > dynamically > as a variable in itself. Consider this typical variable assignment: > $recipe = "spaghetti"; > Interestingly, you can treat the value spaghetti as a variable by placing a > second > dollar sign in front of the original variable name and again assigning > another value: > $$recipe = "& meatballs"; > This in effect assigns & meatballs to a variable named spaghetti. > Therefore, the following two snippets of code produce the same result: > echo $recipe $spaghetti; > echo $recipe ${$recipe}; > The result of both is the string spaghetti & meatballs. > > Thanks. > > Jim > James D Homme, Usability Engineering, Highmark Inc., > james.homme@xxxxxxxxxxxx, 412-544-1810 > > "The difference between those who get what they wish for and those who > don't is action. Therefore, every action you take is a complete > success,regardless of the results." -- Jerrold Mundis > Highmark internal only: For usability and accessibility: > http://highwire.highmark.com/sites/iwov/hwt093/ > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind