PHP allows you to use dynamic variable names, called variable variables. You can name a variable with the value stored in another variable. That is, one variable contains the name of another variable.
$Bangladesh = 147570; $dhaka = 11500; $cityname = "Bangladesh"; echo "The size of $cityname is ${$cityname}"; $cityname = "dhaka"; echo "The size of $cityname is ${$cityname}";
The size of Bangladesh is 147570 The size of dhaka is 11500
Ref: https://www.dummies.com/programming/php/how-to-use-php-variable-variables/
No comments:
Post a Comment