Question and answer is powered by AnsPress.io
$var = ‘foo’;
$$var = ‘bar’;
echo $foo;
What will be the output?
Difference Between $var and $$var in PHP. $$var uses the value of the variable whose name is the value of $var. … 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.
if $name is “test” then $$name would be $test
otherwise $name would just be “test”
let’s say $name is reference to memory address,
so here $$name exactly $($name) is another reference to another memory address.
Its. Called single ($) doller and another called double ($$) doller in Php … The differenc is. In single doller ($) is a normal varible which stores any valuw like string,int,and float. In otherwords $$ (doube) dolller is unreference variable which store value of single $ inside it.
$$name.it dynamic variable. let support you have country value in name variable.so you can call it like this.echo $country.