I don't understand concept of variable variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I don't understand concept of variable variable

means how it works

27th Dec 2016, 11:57 AM
Mayur Bagul
Mayur Bagul - avatar
7 Answers
+ 4
as an example: <?php //You can even add more Dollar Signs $Bar = "a"; $Foo = "Bar"; $World = "Foo"; $Hello = "World"; $a = "Hello"; $a; //Returns Hello $a; //Returns World $$a; //Returns Foo $$a; //Returns Bar $$$a; //Returns a $$$a; //Returns Hello $$$$a; //Returns World //... and so on ...// ?>
27th Dec 2016, 1:00 PM
Kamil
Kamil - avatar
+ 3
sorry, I don't get your question. Could you explain what do you mean with "variable variables"
27th Dec 2016, 12:38 PM
Kamil
Kamil - avatar
+ 2
ohhhh now I get it, you mean the $-concept. it's simple: $name = "Hello"; $name = "World!"; now the first variable $name stores the string "Hello" and the second variable, which is now $Hello stores the string "World!" to output them you can use: <?php echo "$name ${$name}"; ?> or: <?php echo "$name $Hello"; ?>
27th Dec 2016, 12:54 PM
Kamil
Kamil - avatar
+ 1
a variable is a place where you can store information and access it later
27th Dec 2016, 12:24 PM
Kamil
Kamil - avatar
+ 1
thanks kamil somehow its helping me
27th Dec 2016, 3:48 PM
Mayur Bagul
Mayur Bagul - avatar
0
I want variable variables meaning not variable. I know variable is what but I don't understand the concept of variable variables
27th Dec 2016, 12:33 PM
Mayur Bagul
Mayur Bagul - avatar
0
well its a concept in php called variable variables
27th Dec 2016, 12:46 PM
Mayur Bagul
Mayur Bagul - avatar