I am new to PHP, and I just want to ask that some time I see the PHP coding( the codes, available on net) in whoch the variable name contains 2 doller sign.
like
return $$x;
is it just by mistake or it has special effect ?
Thank u very much
new to PHP
Moderators: egami, macek, gesf
It means a variable variable! Sounds complicated but it's quite simple!
Say you have two variables:
$apple = 5;
$orange = 10;
And the user selects a $fruit variable, so $fruit = "apple", then $$fruit = 5. This is because $fruit = "apple", and then you've got another $ sign, so it's $apple which we know to be 5!
Say you have two variables:
$apple = 5;
$orange = 10;
And the user selects a $fruit variable, so $fruit = "apple", then $$fruit = 5. This is because $fruit = "apple", and then you've got another $ sign, so it's $apple which we know to be 5!