Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa PHP What is the special meaning of __sleep and __wakeup?

Have Programming Question? Ask it here!
 
 
 


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


What?s the special meaning of _sleep and _wakeup?


Advertisement
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
 

 

 

DMCA.com