1. __get()/__set() – These are magic getters and setters for getting and putting values for class properties created dynamically.
  2. __isset() – This magic method will be invoked automatically while checking whether a required overloaded property is set or not.
  3. __unset() – Similarly, when we call PHP unset() function on such dynamically created properties, this magic method will automatically be invoked.
  4. __call()/__callStatic() – These two magic methods are dedicated for accessing dynamically created but invisible methods on PHP method overloading.
  5. __sleep() – This will be invoked on calling PHP serialize() function.
  6. __wakeup() – It will do the reverse work to restore objects properties and resources.
  7. __toString() – This method is expected return a string value while using class instances with PHP printing statements.
  8. __invoke()-This method defined in a class will be called when we make a function call with the name of that class instance.
  9. __set_static()-This is a static method invoked while exporting objects property array and expects such array variable as its argument.
  10. __clone()-This function is used while PHP Object Cloning.
  11. __construct()/__destruct()
Categories: BlogPHP

0 thoughts on “PHP Magic Methods”

Leave a Reply

Latest Article


Samsung Galaxy S8 might get a Portrait Mode with the next update

One of the hottest cell phone camera includes this year has seemingly been the Portrait mode, which enables a client to obscure the foundation of a subject along these lines giving more profundity to the Read more…


Huawei Mate 10 Lite with 18:9 display and four cameras declare

Huawei declare its leaders Mate 10 and Mate 10 Pro. In any case, in an unexpected move, Huawei has now quietly declared the spending gadget. The Huawei Mate 10 Lite too accompanies a stretched 5.9-inch Read more…


Xiaomi becomes India’s fastest growing smartphone brand

Riding on the accomplishment of its Redmi Note 4 gadget, Xiaomi has turned into the quickest developing cell phone mark in the second from last quarter of 2017, with a development of 292 for every Read more…