jeboy Posted April 30, 2008 Share Posted April 30, 2008 What is the purpose of "=&"? e.g. $var =& new object($subject); Link to comment https://forums.phpfreaks.com/topic/103525-what-is-the-purpose-of-this-operator/ Share on other sites More sharing options...
GingerRobot Posted April 30, 2008 Share Posted April 30, 2008 The & operator is the reference operator. A reference is like an alias - if one variable is a reference to another, then a change to either will result in both changing: <?php $var = 'foobar'; $var2 = &$var; $var = 'test'; echo $var2; ?> Link to comment https://forums.phpfreaks.com/topic/103525-what-is-the-purpose-of-this-operator/#findComment-530112 Share on other sites More sharing options...
jeboy Posted April 30, 2008 Author Share Posted April 30, 2008 The & operator is the reference operator. A reference is like an alias - if one variable is a reference to another, then a change to either will result in both changing: <?php $var = 'foobar'; $var2 = &$var; $var = 'test'; echo $var2; ?> In your example ($var2 = &$var), does it differ from $var =& new object(); ? Because it's an assignment operator which instantiate an object and call it $var. Link to comment https://forums.phpfreaks.com/topic/103525-what-is-the-purpose-of-this-operator/#findComment-530118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.