Home > Article > Backend Development > Section 11--Reloading_PHP Tutorial
/*
+-------------------------------------------------- ----------------------------------+
| = This article is read by Haohappy<
| = Notes from the Chapter Classes and Objects
| = Translation + personal experience
| = To avoid possible unnecessary trouble, please do not reprint, thank you
| = We welcome criticisms and corrections, and hope to make progress together with all PHP enthusiasts!
| = PHP5 Research Center: http://blog.csdn.net/haohappy2004
+---------- -------------------------------------------------- ------------------+
*/
Section 11--Overloading
There is already overloading syntax in PHP4 to create Mapping of external object models, just like Java and COM. PHP5 brings powerful object-oriented overloading, allowing programmers to build custom behaviors to access properties and call methods.
Overloading can be done through __get, __set, and __call are several special methods. When the Zend engine tries to access a member and cannot find it, PHP will call these methods.
In Example 6.14, __get and __set replace all accesses to the attribute variable array . If necessary, you can implement any type of filtering you want. For example, the script can disable setting property values, start with a certain prefix or include a certain type of value. The
__call method illustrates how you can call a property without Defined method. When you call an undefined method, the method name and the parameters received by the method will be passed to the __call method, and PHP returns the value of __call to the undefined method.
Listing 6.14 User-level overloading