Demonic Posted November 5, 2007 Share Posted November 5, 2007 I seen this a lot in IPB and vBulletin coding, what does this do? Link to comment https://forums.phpfreaks.com/topic/76127-solved-what-does-the-symbol-do-when-put-infront-of-another-variable/ Share on other sites More sharing options...
btherl Posted November 6, 2007 Share Posted November 6, 2007 It creates a reference. You should stay away from these unless you know what you're doing A simple example: $a = 5; $b = &$a; $b = 2; print "a now has value $a\n"; When you make $b a reference to $a, the variables become shared. Changes to either one will affect both. Only one copy of the actual data is stored. PS In general it's a bad idea to use references to try to save memory. PHP already has mechanisms that save memory in most common situations where variables are copied. Link to comment https://forums.phpfreaks.com/topic/76127-solved-what-does-the-symbol-do-when-put-infront-of-another-variable/#findComment-385294 Share on other sites More sharing options...
Demonic Posted November 6, 2007 Author Share Posted November 6, 2007 oh shit, like a refernces/pointers in C/C++? Link to comment https://forums.phpfreaks.com/topic/76127-solved-what-does-the-symbol-do-when-put-infront-of-another-variable/#findComment-385334 Share on other sites More sharing options...
trq Posted November 6, 2007 Share Posted November 6, 2007 Exactly. Link to comment https://forums.phpfreaks.com/topic/76127-solved-what-does-the-symbol-do-when-put-infront-of-another-variable/#findComment-385342 Share on other sites More sharing options...
Demonic Posted November 6, 2007 Author Share Posted November 6, 2007 Thats pretty cool . Link to comment https://forums.phpfreaks.com/topic/76127-solved-what-does-the-symbol-do-when-put-infront-of-another-variable/#findComment-385353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.