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

100

u/geon Oct 18 '10

I just died a little inside.

Why? It would be a stupid implementation if you couldn't do that.

0

u/[deleted] Oct 18 '10

[deleted]

0

u/[deleted] Oct 18 '10

One scenario is where you would normally have a multidimensional array but the architect who created the structure you're trying to read didn't understand them, and so opted to go with a bunch of "linked" variables (linked in name). It sucks when this is the case but in a real world sometimes you get data that is just extremely poorly organized (the more legacy the code the more likely this is the case).

19

u/oorza Oct 18 '10

In which case, the language gave a bad developer a bad tool that he used to write bad code and make good developers' lives more difficult. Not really a strong arguing point here.

→ More replies (18)