[nycphp-talk] Passing Arrays
David Mintz
dmintz at davidmintz.org
Tue Oct 28 12:33:47 EST 2003
On Tue, 28 Oct 2003, Analysis & Solutions wrote:
> Hi Jim:
>
> On Mon, Oct 27, 2003 at 05:53:56PM -0500, Jim Smith wrote:
> > With PERL, if passing two arrays to a subroutine the arrays should be
> > passed as references to ensure their integrity.
> >
Oh, you mean so they don't get flattened into a single list.
> > Should this also be applied with PHP?
>
> Just curious, are you delcaring the function with arguments, or are you
> grabbing them via func_get_args()?
>
> Either way, I don't believe you HAVE to.
>
> Are you changing data in either of those arrays inside the function? If
> so, then passing by reference is more efficient.
>
Is it not so that PHP -- I'm gonna try to say this intelligibly --
doesn't actually copy data that is passed-by-value unless and until you
change it inside the function? So pass-by-reference isn't necessary unless
it's what you really mean. Stated differently, passing by reference just
for the sake of saving memory doesn't save memory. True?
---
David Mintz
http://davidmintz.org/
Email: See http://dmintzweb.com/whitelist.php first!
"Anybody else got a problem with Webistics?"
Sopranos 24:17
More information about the talk
mailing list