The magic method _sleep() and _wakeup() is called when an object is serialized. The magic method _sleep() and _wakeup() provides a method to clean up and restore objects before being serialized.
Working with _sleep()
_sleep() magic method is called when the object of a class is about to be serialized. This magic method _sleep() does not accept any parameter and returns an array. The array should contain a list of class members that should be serialized. This means that if you donâ€™t wish to serialize a particular class member, you should not include it in the array. Look at the example below: Continue reading »