FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » out of sheer curiosity...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: out of sheer curiosity... [message #177553 is a reply to message #177552] Mon, 09 April 2012 18:04 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
Jerry Stuckle schrieb:

> The __clone() method is a form of a constructor. But wakeup() isn't.

Neither is. Cloning simply copies a previously constructed object while
__wakeup() changes the state of a previously constructed object.

> And if you argue that wakeup() is a form of a constructor,

I don't and never did.

> then you have
> to argue that sleep() is a form of a destructor - in which case it would
> be invalid to call the destructor after calling sleep().

Serialization creates a kind of "frozen" copy of an object. The original
object continues to exist and its destructor is called as expected.
Later, the "frozen" copy is "warmed up" and can pretend to be the
original object, but it is not the same object. The __sleep() and
__wakeup() methods simply assist with the freezing and warming up and
have nothing to do with the copying.

To sum it up: A new object can be created by either constructing it
(which calls __construct()) or by copying an existing object (via clone
or via serialization) and this happens without calling __construct() on
the copy since the object is already constructed. And this explains why
there may be more __destruct() calls than __construct() calls in a script.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 5.4 windows installer.
Next Topic: Does PHP5 treat $_SERVER['PHP_AUTH_USER']) differently?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 05:59:09 GMT 2024

Total time taken to generate the page: 0.04760 seconds