Difference between $variable and $$variable

Indirect Reference used in the $$variable.
We explain the difference between $variable and $$variable through below example:-

Suppose, we create two variables.
(1) $variable which has value name.
(2) second variable name is the value of the first variable.


<?php
$variable = "name";
$name="John";
echo $variable;
?>
Output: John

Work Flow of the above example


$variable;

$$variable now process will work from right to left.


$name

after that output is


John

Difference between $variable and $$variable – Objective Questions (MCQs)

Q1. What does $$variable represent in PHP?






Q2. If $a = "name" and $name = "PHP", what is $$a?






Q3. Which symbol is used to create variable variables?






Q4. What is $variable in PHP?






Q5. Which is a valid use of variable variables?






Related Difference between $variable and $$variable Topics