[nycphp-talk] What does function &get_ref() {} do?
Hans Zaunere
hans at nyphp.org
Wed Sep 3 10:35:47 EDT 2003
This is always a confusing topic, and I'd just like to point a couple things out; hopefully without confusing it more.
>>doesn't this need global $var_1,$var_2; in the swap function?
>
> No. Normally variables passed to functions are just copies used in the function scope.
Actually, variables are always passed by reference, although they are "weak". This means that as long as a argument isn't written to or changed in any way, inside the function, the variable's contents aren't copied. Only when the argument is written to, are the contents copied, ie copy-on-write. This doesn't apply, however to objects, IIRC.
H
More information about the talk
mailing list