PHP - How Practical Is This?

  • From: james.homme@xxxxxxxxxxxx
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 5 Aug 2008 07:34:39 -0400

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

Other related posts: