straygrey Posted May 11, 2011 Share Posted May 11, 2011 What is the difference between $foo = Bar::getInstance(), and $foo = &Bar::getInstance(), assuming Bar::getInstance() returns an instance of the class named “Bar”? Does &Bar return the address of rather than the instance? Quote Link to comment https://forums.phpfreaks.com/topic/236093-difference-between-bar-bar/ Share on other sites More sharing options...
gizmola Posted May 12, 2011 Share Posted May 12, 2011 That syntax should not be used. Back in the PHP4 days, the way objects were passed required the use of & in many cases, but in PHP5 all objects are passed by reference. In PHP there aren't really pointers, but the general idea is the same -- making a copy of a data structure vs. using the actual data structure. Objects are automatically passed by reference now. Quote Link to comment https://forums.phpfreaks.com/topic/236093-difference-between-bar-bar/#findComment-1214298 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.