Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

What is the special meaning of __sleep and __wakeup?

Ads

 
 

Share on Google+Share on Google+

brijesh
What is the special meaning of __sleep and __wakeup?
1 Answer(s)      6 years and 8 months ago
Posted in : PHP

What?s the special meaning of _sleep and _wakeup?

Ads
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


Ads