twitter
    Find out what I'm doing, Follow Me :)
If you have any question, suggestion or article topic for me to write, feel free to contact me through my shout box. ;) Some time I need an idea to write. hehe Hopefully I can help you and share my expertise.

php variable variables

I'm sure, some time we need to create variable dynamically. the normal variable declaration in PHP is starting with dollar signs $ .
an example

$fruit = 'banana';
$fruit is a variable when 'banana' is a string value for that variable. when we do echo $fruit, the result is 'banana'.
an example

$fruit = 'banana';
echo $fruit;
//result : banana
This is a static variable. How about when I want to create new variable in a run time?. You can do it by adding double dollar sign
an example

$fruit = 'banana';
$$fruit = 'durian';
echo $banana;
//result : durian

You can download sample file : How to use variable variables in php
more information

0 comments:

Post a Comment