NYCPHP Meetup

NYPHP.org

[nycphp-talk] I need a very elementary-school explanation of ' &'

Phil Powell phillip.powell at adnet-sys.com
Thu Feb 19 17:26:24 EST 2004


Well, so as long as I do not have to change my code as I have always 
used "$obj =& new Object()" as my assignment operation of choice to 
assign by reference (using PHP 4.3.2 here)

Phil

Adam Maccabee Trachtenberg wrote:

>On Thu, 19 Feb 2004, David Mintz wrote:
>
>  
>
>>Further -- again, pls correct me if I'm wrong, as I'm just the bat boy
>>among the heavy hitters here -- PHP5 will pass/assign objects by reference
>>*by default*, so you have to clone off a copy if you *don't* want that.
>>The =& notation will become superfluous.
>>    
>>
>
>This is correct. In PHP 5, objects are passed and assigned by
>reference and you need to use the clone operator to duplicate them.
>
>$original = new van_gogh_painting;
>$knock_off = clone $original;
>
>You can control the cloning process by defining a __clone() method
>inside the class; otherwise, you just get regular copy of all the
>object properties.
>
>-adam
>
>  
>


-- 
Phil Powell
Web Developer
  ADNET Systems, Inc.
  11260 Roger Bacon Drive, Suite 403
  Reston, VA  20190-5203
Phone: (703) 709-7218 x107   Cell: (571) 437-4430   FAX: (703) 709-7219
EMail:  Phillip.Powell at adnet-sys.com      AOL IM: SOA Dude








More information about the talk mailing list