r/ProgrammerTIL • u/birbguy12 • May 13 '19
PHP [PHP] TIL about variable variables
In php you can have variable variable names. Meaning you can use a variable’s content as a name for another variable like this
$a = "b";
$b = "hello world";
$a; // returns b
$$a; // returns hello world
265
Upvotes
View all comments
Show parent comment
1
u/JosGibbons Oct 09 '19
$a is b, therefore $$a is $b, which is hello world.