View Single Post
Old 01-27-2008, 09:40 AM   #8 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

If you need to pass by reference instead of value, use the referencing operator in the function declaration, instead of sending a reference at call time. Like so:

PHP Code:
do_stuff( &$var 
becomes:

PHP Code:
do_stuff$var );

function 
do_stuff( &$var 
References will not create a copy of the variable being sent, but instead use the memory handle of that variable to manipulate it. I don't know if there is actually more to know about them, but the fact that a reference to a variable points to the same variable, where as a copy points to another, different, variable (changing the reference affects the original variable, changing the copy does not).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote