What is the special meaning of __sleep and __wakeup?

What?s the special meaning of _sleep and _wakeup?

View Answers

November 15, 2010 at 3:23 PM

Hi all,

Special meaning of sleep : This is the magic function in php. serialize() checks if your class has a function with the magic name _sleep. If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn?t return anything then NULL is serialized and E_NOTICE is issued.

special meaning of wakeup : This is the magic function in php. unserialize() checks for the presence of a function with the magic name _wakeup. If present, this function can reconstruct any resources that the object may have.

Thanks









Related Tutorials/Questions & Answers:
Advertisements