PHP, which starts with two underscores, is called the Magic Method (Magic methods), which plays a pivotal role in PHP. Here is a detailed introduction, interested in the small friends can refer to.
PHP, which starts with two underscores, is called the Magic Method (Magic methods), which plays a pivotal role in PHP. Magic methods include:
- __construct (), constructor of class
- __destruct (), Destructor for class
- __call (), called when an inaccessible method is called in an object
- __callstatic (), called when a non-accessible method is called in a static manner
- __get (), which is called when a member variable of a class is obtained
- __set (), which is called when a member variable of a class is set
- __isset (), called when isset () or empty () is called on an inaccessible property
- __unset () is called when unset () is called on a non-accessible property.
- __sleep (), when executing serialize (), this function is called first
- __wakeup (), when executing unserialize (), this function is called first
- __tostring (), which is a method of responding when a class is treated as a string
- __invoke (), called when a function is called in a way that responds to an object
- __set_state (), this static method is called when the Var_export () export class is called.
- __clone (), called when the object copy is complete
- __autoload (), attempting to load an undefined class
- __debuginfo () to print the required debug information
For more information, please see below:
http://php.net/manual/zh/language.oop5.magic.php
Ext.: http://www.jb51.net/article/96167.htm
PHP 16 Magic Methods Detailed Introduction