Reply to Re: PHP brain teaser

Your name:

Reply:


Posted by Tim Van Wassenhove on 01/13/06 06:42

On 2006-01-13, Chung Leong <chernyshevsky@hotmail.com> wrote:
> Here's a little brain teaser distilled from a bug that took me a rather
> long time to figure out. The two functions in the example below behave
> differently. The difference is easy to spot, of ocurse. The challenge
> is correctly explaining why this is so. Why does the second function
> seemingly corrupt the cloned copy of an object?

My guess is the following:
When php initializes a new object (copy/clone) it will notice that in the second
method the reference count to $obj->attributes is 2. Therefore it will assign
new memory for the copied/cloned instance. This explains why we see 0 instead of
14.

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>

[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

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