What are magic functions?

  • Magic Methods allow you to react to certain events when using these particular objects. This means when certain things happen to your object, you can define how it should react in that instance.
  • They start with double underscore
  • They are always defined inside of the class
  • They are never called directly

 

Examples:

__construct(), __destruct(), __call(), __callStatic(), __get(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __invoke(), __set_state(), __clone() and __debugInfo()

Leave a Reply

Your email address will not be published. Required fields are marked *