frijole Posted February 11, 2008 Share Posted February 11, 2008 I found this in some code I am looking through and I do not know if this serves some function or if it is a typo? $$field = $value; ?? Quote Link to comment https://forums.phpfreaks.com/topic/90450-field-value-are-the-two-a-typo/ Share on other sites More sharing options...
vbnullchar Posted February 11, 2008 Share Posted February 11, 2008 no thats not a typo.. it is called a variable variables Quote Link to comment https://forums.phpfreaks.com/topic/90450-field-value-are-the-two-a-typo/#findComment-463708 Share on other sites More sharing options...
frijole Posted February 11, 2008 Author Share Posted February 11, 2008 can anyone explain the purpose of that? Quote Link to comment https://forums.phpfreaks.com/topic/90450-field-value-are-the-two-a-typo/#findComment-463724 Share on other sites More sharing options...
nethnet Posted February 11, 2008 Share Posted February 11, 2008 That syntax is used for dynamic variable nomenclature... in other words, if $field is equal to "hello", then a new varialbe called $hello would be created and set to the value of $value. Theo Quote Link to comment https://forums.phpfreaks.com/topic/90450-field-value-are-the-two-a-typo/#findComment-463732 Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2008 Share Posted February 11, 2008 Variable variables should only be used when necessary. Most of the time using an array is more appropriate and results in less code. Code using variable variables is also 2-3 times slower than using an array. Quote Link to comment https://forums.phpfreaks.com/topic/90450-field-value-are-the-two-a-typo/#findComment-463736 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.