Variable within Another Variable
A quick quiz ...
Is this code legal? ...
<?php
$fruit = "apple";
$temp = "fruit";
print($$temp);
?>
If you answered "Yes", congrats ... you are right. If you said "No", better luck next time!
Read on!
$$temp actually evaluates to $fruit. Hence, the code is legal and the word "apple" is printed.
Is this code legal? ...
<?php
$fruit = "apple";
$temp = "fruit";
print($$temp);
?>
If you answered "Yes", congrats ... you are right. If you said "No", better luck next time!
Read on!
$$temp actually evaluates to $fruit. Hence, the code is legal and the word "apple" is printed.

0 Comments:
Post a Comment
<< Home