Reply to Re: PHP4/5 deep copy?

Your name:

Reply:


Posted by Wayne on 08/27/05 02:54

On Fri, 26 Aug 2005 16:50:00 -0400, "Kevin" <kevin@wxREMOVE4SPAM3.com>
wrote:

>PHP5 copies by reference by default, so this doesn't work--- I'm not
>modifying the copies, I'm modifying the original. I read about a trick to
>create a PHP4/PHP5 compatible clone function, but that doesn't work either.
>PHP5's clone is a shallow copy, so the properties of the original which are
>other objects only get referenced.

PHP5 automatically calls a function called __clone() during the
cloning process. This can be used to make deep clones of objects by
cloning all the object properties.

Example:

class Test {
function __clone() {
$this->property1 = clone($this->property1);
$this->property2 = clone($this->property2);
}

That might help.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация