NYCPHP Meetup

NYPHP.org

[nycphp-talk] array of object being passed by reference problem

Daniel Convissor danielc at analysisandsolutions.com
Mon Dec 8 11:28:49 EST 2003


Hi Jeff:

On Mon, Dec 08, 2003 at 09:58:40AM -0500, Jeff Barrett wrote:
> 
> function & method1()
> {
> 	return $this->arrayOfPointers;
> }
> 
> Notice the & before the method1, that does some nice magic. Makes the
> function return pointers,

Do note a few things.  They're called "references," which are kind of like
pointers, but aren't true pointers.  Establishing a function like that is
termed "returning by reference."  Only return variables from such methods.  
Most people use the style with the & is next to the function name:  
"function &method()"  Finally, the reference isn't created unless the call
to the function says it should via the =&:

   $foo =& method1();

--Dan

-- 
     FREE scripts that make web and database programming easier
           http://www.analysisandsolutions.com/software/
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409



More information about the talk mailing list