Page 1 of 1

When to use a variable variable in PHP?

Posted: Wed May 31, 2017 9:03 am
by indr9864
I've been developing in PHP for a while now, and I still have not had a task where I've had to use variable variables. Can anyone give me examples where using them is a good idea ? Or were they included in the language for no reason ?

Re: When to use a variable variable in PHP?

Posted: Mon Jun 26, 2017 9:10 am
by anab6077
I also have the same problem. Looking help from someone.

Re: When to use a variable variable in PHP?

Posted: Thu Jun 29, 2017 10:50 am
by mani3164
Variable use Doller sign

Re: When to use a variable variable in PHP?

Posted: Sat Jul 08, 2017 6:44 am
by frie3144
Friendship day is celebrated on the first Sunday of August in every year. This day is also special for your friendship if you have the best friend or if you have any loyal, faithful friend.

Re: When to use a variable variable in PHP?

Posted: Sat Jul 08, 2017 7:01 am
by frie3144
Friendship day is celebrated on the first Sunday of August in every year. This day is also special for your friendship if you have the best friend or if you have any loyal, faithful friend.

Re: When to use a variable variable in PHP?

Posted: Tue Aug 29, 2017 10:24 pm
by alek76
I use those very rarely. Usually when you have some sort of condition:

Code: Select all

if ($a){
$varname = 'fullname';
} else {
$varname = 'name';
}
echo $$varname; 
This is the same as

Code: Select all

if ($a){
echo $fullname;
} else {
echo $name;
} 
And although this is a simple case in which there is no need to use the variable variable - you may get more complex cases where that is the only way to achieve the desired result.

Re: When to use a variable variable in PHP?

Posted: Tue Jan 09, 2018 7:53 am
by neha550
I use it for loading existing user values from the database. I use it for passing my form fields back to smarty:

Re: When to use a variable variable in PHP?

Posted: Tue May 15, 2018 1:51 am
by Bepannaah
Thank you so much for sharing such a superb informations with us. Your website is very cool. we are impressed by the details that you have on your site.we Bookmarked this website. Thanks again
http://bepannaah.com/