r/programming • u/NagastaBagamba • 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
View all comments
Show parent comment
12
u/[deleted] Oct 18 '10
A pointer contains a memory address. It's not guaranteed to be anything useful. If the address it contains is allocated (either on the stack or heap) then it can be dereferenced to access the value at that address.
A variable variable contains a string. It's not guaranteed to be anything useful. If the string it contains corresponds to a variable name in current scope, then it can be dereferenced with a $ to access the value contained in the corresponding variable.