x_maras Posted July 30, 2009 Share Posted July 30, 2009 Hi, I saw in a code a variable with 2 dollars. Couldnt be wrong because the code was working, but I tried this by my self: <?php $something = "bla test"; $$something = $something; echo $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$something; ?> and it works it prints "bla test". But, if you change the second line, for example : $$something = "print this"; it gives an error. The same happens if you change the name of the second variable: <?php $something = "bla test"; $$thing = $something; echo $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$thing; ?> This also gives an error. Does anyone knows what exactly this does? Quote Link to comment https://forums.phpfreaks.com/topic/168106-2-or-more-in-front-of-a-variable/ Share on other sites More sharing options...
RichardRotterdam Posted July 30, 2009 Share Posted July 30, 2009 The double dollar is a variable variable. variables.variable Personally I don't really see the point of using them I rather use arrays. But you could use them. Quote Link to comment https://forums.phpfreaks.com/topic/168106-2-or-more-in-front-of-a-variable/#findComment-886627 Share on other sites More sharing options...
avvllvva Posted July 30, 2009 Share Posted July 30, 2009 Here is the use of $$, <?php $testing = "The actual content of string"; $something = "testing"; echo $$something ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/168106-2-or-more-in-front-of-a-variable/#findComment-886633 Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2009 Share Posted July 30, 2009 Variable variables take three times longer to access than an array variable does, they should not really be used. Quote Link to comment https://forums.phpfreaks.com/topic/168106-2-or-more-in-front-of-a-variable/#findComment-886845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.