An Exception is an abnormal (Unwanted) conditions which arise at the time of execution of Program.I also say exception is “Run-Time Error”. Concept of exception was introduced in PHP 5 with OOP.Exception interrupt the program flow if something goes wrong in it.(exception e). e is an object of class.An exception is an object that is thrown by program.
PHP OOP
Same as other magic functions, these functions also adds some magic functionality to your code. __invoke calld once object is treated like a function. __clone is called once the object cloning is done. __toString will decide how the class should behave when treated as a string.
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.
__sleep and __wakeup function will call once you make the serialize() and unserialize() operation to your class object.
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.
