note 34306 added to language.references.whatdo

From: Date: Wed, 23 Jul 2003 16:13:03 +0000
Subject: note 34306 added to language.references.whatdo
Groups: php.notes 
Request: Send a blank email to php-notes+get-52501@lists.php.net to get a copy of this message
Re: ampersands in function definitions There is a prior comment that "in practice you won't need ampersands in function definitions." This is not really true; ampersands in function definitions *do* change the way PHP behaves. I have an application that has an array of "references to objects". A function that wants to return a reference to an object requires the "function &foo()" notation. If the ampersand is missing, a copy of the object is made, regardless if the invocation is "$obj = foo()" or "$obj =& foo()". For many applications, the difference between "function &foo()" and "function foo()" won't be apparent, simply because return by value is the correct behavior. ---- Manual Page -- http://www.php.net/manual/en/language.references.whatdo.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34306 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34306&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34306&report=yes

« previous php.notes (#52501) next »