NYCPHP Meetup

NYPHP.org

[nycphp-talk] Passing Arrays

George Webb gw.nyphp at gwprogramming.com
Tue Oct 28 15:08:37 EST 2003


Hi all.  Just another too sense:

	In case it's not already obvious, PHP doesn't "flatten"
multiple arrays into a single array in a function argument list.
E.g. you can send three different arrays to a function and they
will each remain independent.

	Regarding passing references versus values for arguments,
I recall hearing from an expert at last year's PHPCON (West) that
passing references (instead of values) doesn't really save memory.
(David Mintz began saying this already....) I believe this is
because PHP's internal copying of an array is so efficient.  However,
I would assume that this is only true for arrays that are not "huge"...
if you want to pass a "huge" array to a function, I believe it
would be better to pass a reference instead of the regular way.

	What constitutes "huge" is probably hard to determine
exactly.  I would guess maybe an array larger than a megabyte or so.

	Also, you can conveniently specify pass-by-reference in
either the call to the function or in the function's declaration.


Best, George.

George Webb
gw.nyphp at gwprogramming.com



More information about the talk mailing list
Automatic Email Organization without missing anything!