Home >Backend Development >PHP Tutorial >--- Section 11--Reloading
/*
+------------------------------------------------ ----------------------------------+
| = This article is read by Haohappy<
| = Notes from the Chapter Classes and Objects
| = Translation + personal experience
| = To avoid unnecessary trouble that may occur, please do not reprint, thank you
| = Welcome to criticize and correct, hope and all PHP enthusiasts Make progress together!
| = PHP5 Research Center: http://blog.csdn.net/haohappy2004
+-------------------------- -------------------------------------------------- ---+
*/
Section 11--Overloading
PHP4 already has overloading syntax to establish mapping to external object models, just like Java and COM. PHP5 brings powerful object-oriented Overloading allows programmers to create custom behaviors to access properties and call methods.
Overloading can be performed through several special methods __get, __set, and __call. When the Zend engine tries to access a member and does not find it, PHP These methods will be called.
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 attribute values at the beginning Use a certain prefix or contain a certain type of value. The __call method explains how you call an undefined 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 passes_ The value of _call is returned to the undefined method.
Listing 6.14 User-level overloading
Copy the code The code is as follows:
class Overloader