Re: [PHP] Return Values Copied? Copied if By Reference?

2006-08-03 Thread Richard Lynch
On Thu, July 27, 2006 1:05 pm, Adam Zey wrote: Then how come when I do a foreach on an array (without modifying anything within the foreach), it still makes a copy of the array that consumes memory? I think it's dangerous to generalize that it's always best to let PHP make copies of things. In

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-27 Thread Robert Cummings
On Thu, 2006-07-27 at 01:35, Larry Garfield wrote: On Wednesday 26 July 2006 21:41, Robert Cummings wrote: I'm working on some code that would be called to generate a cell in a possibly large table and therefore a small difference in performance may have a significant impact. PHP

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-27 Thread Adam Zey
Robert Cummings wrote: On Thu, 2006-07-27 at 01:35, Larry Garfield wrote: On Wednesday 26 July 2006 21:41, Robert Cummings wrote: I'm working on some code that would be called to generate a cell in a possibly large table and therefore a small difference in performance may have a significant

RE: [PHP] Return Values Copied? Copied if By Reference?

2006-07-27 Thread KermodeBear
Robert Cummings wrote: Then how come when I do a foreach on an array (without modifying anything within the foreach), it still makes a copy of the array that consumes memory? I think it's dangerous to generalize that it's always best to let PHP make copies of things. In the foreach situation,

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-27 Thread Adam Zey
KermodeBear wrote: Robert Cummings wrote: Then how come when I do a foreach on an array (without modifying anything within the foreach), it still makes a copy of the array that consumes memory? I think it's dangerous to generalize that it's always best to let PHP make copies of things. In

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-27 Thread Robert Cummings
On Thu, 2006-07-27 at 14:48, Adam Zey wrote: KermodeBear wrote: Robert Cummings wrote: Then how come when I do a foreach on an array (without modifying anything within the foreach), it still makes a copy of the array that consumes memory? I think it's dangerous to generalize that

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-26 Thread Robert Cummings
On Wed, 2006-07-26 at 22:29, Michael B Allen wrote: Is a function return value copied? If the value is an integer I suppose it is but what about a string or an array? If you pass by reference is the return value still copied? For example, is this: function foo($arr) { $arr[] =

Re: [PHP] Return Values Copied? Copied if By Reference?

2006-07-26 Thread Larry Garfield
On Wednesday 26 July 2006 21:41, Robert Cummings wrote: I'm working on some code that would be called to generate a cell in a possibly large table and therefore a small difference in performance may have a significant impact. PHP uses copy-on-write and so copies are essentially shared