PHP5 has provided magic methods to make Object Oriented Programming (OOP) easier. These magic methods are specially named methods for all classes, which are called automatically in certain scenarios.
Some Magic methods in PHP5
| __construct() | Called when an object is instantiated. |
| __destruct() | Called when an object is destroyed. |
| __call() | Provide actions or return values when undefined methods are called on an object. |
| __get () | To specify custom functions to store and retrieve data in properties that are not already defined in the class. It takes one argument, the name of the property. |
| __set() | Same as __get() method but it requires 2 arguments: the name of the property and the new value. |
| __toString() | Returns a custom string value that is automatically used when the object is converted to a string. |
Tags: object orientated php, php5, Web Development

