note 18958 deleted from language.references.whatdo by colder
| From: | colder@php.net | Date: | Sat, 24 Feb 2007 11:44:47 +0000 |
| Subject: | note 18958 deleted from language.references.whatdo by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123818@lists.php.net to get a copy of this message | ||
Note Submitter: todd at nemi dot net
----
tbutzon@imawebdesigner.com Makes an excellent point in his reference examples, however, what you
find in practice is that you do not need the & in the function definition to actually assign the
reference. It is redundant.
The proper way to return a reference is by using:
function &myClass() {
//...some code...
return $this;
}
$myObj =& new myClass()
...however, this produces the exact same result:
function myClass() {
//...some code...
return $this;
}
$myObj =& new myClass()
Apparently, the Ampersand on the assignment is all that is really needed for a reference to truly be
assigned. The Ampersand on the function definition actually does nothing.