June 2017
Intermediate to advanced
536 pages
9h 49m
English
The topic of serializable objects would not be complete without the serialize() method counterpart--the unserialize() method. If the serialize() method call triggers the object's __sleep() magic method, it is logical to expect there is a similar behavior for deserialization. Rightfully so, calling the unserialize() method upon a given object triggers its __wakeup() magic method.
The intended use of __wakeup() is to reestablish any resources that might have been lost during serialization and perform other reinitialization tasks.
Let's take a look at the following example:
<?phpclass Backup{ protected $ftpClient; protected $ftpHost; protected $ftpUser; protected $ftpPass; public function __construct($host, $username, $password) ...