Answers

Question and Answer:

  Home  WordPress Theme Development

⟩ Tell me in PHP, what are magic methods and how are they used?

PHP functions that start with a double underscore – a “__” – are called magic functions (and/or methods) in PHP. They are functions that are always defined inside classes, and are not stand-alone (outside of classes) functions.

The magic functions available in PHP are:

☛ __construct(),

☛ __destruct(),

☛ __call(),

☛ __callStatic(),

☛ __get(),

☛ __set(),

☛ __isset(),

☛ __unset(),

☛ __sleep(),

☛ __wakeup(),

☛ __toString(),

☛ __invoke(),

☛ __set_state(),

☛ __clone(), and

☛ __autoload().

 130 views

More Questions for you: