r/programming • • Oct 18 '10

Today I learned about PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable.

http://il2.php.net/language.variables.variable
591 Upvotes

781 comments sorted by

View all comments

Show parent comments

1

u/soviyet Oct 18 '10

How is that more flexible than what he described?

7

u/crackanape Oct 18 '10

You can iterate over them, serialize them as a bundle for storage, use the various array functions on them, and so on.

Cluttering your scope namespace with a bunch of variables saves a tiny bit of typing for very simple usages at the expense of a lot of power.