note 59204 deleted from language.references.return by nlopess
| From: | nlopess@php.net | Date: | Tue, 29 Nov 2005 18:31:19 +0000 |
| Subject: | note 59204 deleted from language.references.return by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-99314@lists.php.net to get a copy of this message | ||
Note Submitter: dark.ryder
----
"Do not use return-by-reference to increase performance, the engine is smart enough to optimize
this on its own. Only return references when you have a valid technical reason to do it!"
Just to be clear about this (and correct me if I'm wrong), returning by reference is only
necessary when returning a reference to something outside the function's local scope? For
example, it is reasonable to return-by-reference a reference to a globally-scoped or object-scoped
variable, but not to return a reference to a multi-megabyte array which only exists in the
function's local scope, because PHP is smart enough to return the array by reference
automatically to avoid unnecessary memory thrashing?