0

Variable-variables.. no error???

in below program... i am using integer content as variable-variables... but as we know... variable name must not starts with number than how program not showing any error??!!... please explain <?php $x=10; $x=20;//$x=$10 echo('value of the $x is : '.$x); ?>

6th Nov 2017, 5:54 PM
Saurav Kumar
Saurav Kumar - avatar
2 Réponses
+ 2
I think that's because the variable's variable use variable name only as a reference to first variable name. Not the value it self. We can do some test as follow. According to above test you will get $x = 20. But if we try to access $10, it will give you the error you expect. We can assume that PHP uses only a reference to the first variable. Not the value it self. For the record, this is only my personal idea. May be I am wrong. I faced the same situation but I couldn't find enough info on the matter.
12th Nov 2017, 9:14 AM
Sajith Warnasooriya
Sajith Warnasooriya - avatar
+ 1
thanks for help bro.... I thought so... it just taking names but not the value....
12th Nov 2017, 9:31 AM
Saurav Kumar
Saurav Kumar - avatar