The Magic method is a unique feature of PHP object-oriented. They are triggered under certain circumstances, all starting with a double underscore, you can interpret them as hooks, and the pattern method makes it easy to implement PHP object-oriented overloading (overloading, which dynamically creates class properties and methods). Many of the magic methods are still paired, and the following list shows all the schema methods in PHP currently.
1.__construct,__destruct
__constuct is called when the object is built;
__destruct explicitly destroys the object or is called at the end of the script;
2.__get,__set
__set called when an attribute assignment is not accessible or does not exist
__get is called when read is not accessible or there is no property
3.__isset,__unset
__isset called when isset () or empty () is called on an inaccessible or nonexistent property
__unset called when an unreachable or nonexistent property is unset
4.__call,__callstatic
Called when __call calls a method that is not accessible or does not exist
Called when __callstatic calls a static method that is not accessible or does not exist
5.__sleep,__wakeup
__sleep is called when using serialize, which is useful when you don't need to save all the data for a large object
__wakeup is called when using unserialize, and can be used for initialization of objects
6.__clone
Called when the object clone is being used to adjust the cloning behavior of the object
7.__tostring
Called when a class is converted to a string
8.__invoke
Called when an object is called in a functional manner
9.__set_state
This static method is called when the Var_export () export class is called. Use the return value of __set_state as the return value of Var_export.
10.__debuginfo
Called when a var_dump () print object is called (when you do not want to print all properties) for the PHP5.6 version
PHP Magic Method Summary