What is the difference between $name and $$name?

What is the difference between $name and $$name?

$$var uses the value of the variable whose name is the value of $var.
It means $$var is known as reference variable whereas $var is normal variable.
It allows you to have a “variable’s variable” – the program can create the variable name the same way it can create any other string. As example:

<?PHP

$name="Sharique";

$$name="Vishal";

echo $name."<br/>";

echo $$name."<br/>";

echo $Vishal;

?>

Output
Sharique
Vishal
Vishal
 
Back
Top