As other programming/scripting language PHP also have some reserved functions, normally these functions starts with double underscore (__) in PHP.
These reserved functions adds some magic functionality to you code.
Constructor and Destructors are the basic and most familiar reserved functions. Constructor will call once we initialize the object and Desctructor will call once object will destroy.
When you define these functions in your class then it will call once you made call to any method of the class which is not declared/defined yet.
__sleep and __wakeup function will call once you make the serialize() and unserialize() operation to your class object.
As we all know that PHP is the loosely coupled scripting languange. This means we can assign the values to the variables without declaring the variable.
Due to this loosely coupled architecture, PHP have provided two magic functions to handle the store and retrieve request of the undefined variable. Those two methods are __get and __set.
