[nycphp-talk] I need a very elementary-school explanation of ' &'
Phil Powell
phillip.powell at adnet-sys.com
Fri Feb 20 10:13:19 EST 2004
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
>
>
>
By the way am I offbase by also assuming that in PHP version 5 I would
be ensuring that if an object is to be a Singleton, I would have to
"turn off" cloning:
public function __clone() {
trigger_error("Cloning of this object is not supported", E_USER_ERROR);
}
Phil
--
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