If you have already register Login here.
In PHP language, $(dollar sign) is used to store variable data. $$ can be used to store a variable of a variable. Data stored in $ is fixed while data stored in $$(double dollar sign) can be changed dynamically.
such as:
<?php
$x = "php";
$$x = 500;
echo $x."<br/>";
echo $$x."<br/>";
echo $php;
?>
Output : php ,500, 500
In the above example, we have assigned a value to the variable x as PHP. The value of the reference variable $$x is assigned as 500.
Now we have printed the values $x, $$x and $php.
<?php
$var="Hello";
$$var="World";
echo $var. "<br>";
echo $$var. "<br>";
echo "Welcome to $var " . $$var;
?>
Output: Hello, World, Welcome to Hello World
In the above example, we have assigned a value to the variable var as Hello Value of reference variable $$var is assigned as World.
Now we have printed the values $var, $$var, and a string.
© 2022 Easy To Learning. All Rights Reserved | Design by Easy To Learning