PHP allows us to declare variable variables using double dollar ($$).
$$ is used to declare dynamic variables and assigning values to it.
Variable variables allow you to access the contents of a variable without knowing its name directly – it is like declaration of dynamic variables and assigning values. Consider this piece of code:
$a = ‘b’;
$$a = 3;
echo $b; // outputs : 3
in the above example value of $a (b) becomes a variable ($b) and its value is assigned as 3.
In this way we can create dynamic variables using variable variables ($$).
Question for visitors :
What is the out put of below code :