According to the documentation :
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.
The intended use of __wakeup() is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
If my object has not defined __wakeup()
method I can still have reconstructed form of my object using unserialize()
then why this magic method is there in PHP?
Documentation is also saying the same thing that __wakeup()
function can reconstruct any resources that the object may have just like unserialize()
do.
When this magic method __wakeup()
gets called before unserialization starts or after unserialization finished?