colap Posted June 25, 2011 Share Posted June 25, 2011 function &getInstance($boot = true) { static $instance = array(); if (!$instance) { if (!class_exists('Set')) { require LIBS . 'set.php'; } $instance[0] =& new Configure(); $instance[0]->__loadBootstrap($boot); } return $instance[0]; } Why is & there? function &getInstance And is it php4 syntax using the & ?$instance[0] =& new Configure(); Link to comment https://forums.phpfreaks.com/topic/240397-question-with-php-function/ Share on other sites More sharing options...
Cagecrawler Posted June 25, 2011 Share Posted June 25, 2011 & before a function name means the function returns a reference. The second & is to do with references as well, it passes a reference of the Configure object to $instance[0], rather than a copy. Link to comment https://forums.phpfreaks.com/topic/240397-question-with-php-function/#findComment-1234811 Share on other sites More sharing options...
colap Posted June 26, 2011 Author Share Posted June 26, 2011 The second &, obj=& new classname();. Is that php-4 syntax? Link to comment https://forums.phpfreaks.com/topic/240397-question-with-php-function/#findComment-1234865 Share on other sites More sharing options...
Cagecrawler Posted June 26, 2011 Share Posted June 26, 2011 I think so, the manual talks of a change to the errors thrown in PHP4.4.0. Link to comment https://forums.phpfreaks.com/topic/240397-question-with-php-function/#findComment-1234875 Share on other sites More sharing options...
KevinM1 Posted June 26, 2011 Share Posted June 26, 2011 Quote The second &, obj=& new classname();. Is that php-4 syntax? Yes. In PHP 5 objects are automatically passed by reference. Link to comment https://forums.phpfreaks.com/topic/240397-question-with-php-function/#findComment-1234909 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.