Re: Reference return buggy notice?
| From: | Jochem Maas | Date: | Fri, 19 Oct 2007 21:25:36 +0000 |
| Subject: | Re: Reference return buggy notice? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263430@lists.php.net to get a copy of this message | ||
Stut wrote:
...
>
> Say you have a function that builds a fairly large array and then
> returns it. If you just return it as usual PHP will make a copy of that
> array and therefore use twice the amount of memory than it needs to.
php has something called 'copy on change' so until an attempt to make a change on
the returned array is made the doubling of memory usage doesn't occur. afaik.
are there any benchmarks either way?
>
> References also provide a way to return more than one variable from a
> function, but I doubt many PHP developers come across the need to do that.
an example is returning the total count of a given sql statement in an
'by reference' argument whilst returning a 'paged' result set.
>
> Where in the manual does it say that? I've never seen it and I can't
> find it.
say what?
>
> -Stut
>