Home > Backend Development > PHP Tutorial > Section 11 - Overloading - Classes and Objects in PHP5 [11]_PHP Tutorial

Section 11 - Overloading - Classes and Objects in PHP5 [11]_PHP Tutorial

WBOY
Release: 2016-07-20 11:03:38
Original
899 people have browsed it

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, allowing programmers to Build custom behaviors for accessing properties and calling methods.
Overloading can be done through several special methods __get, __set, and __call. PHP will call these when the Zend engine tries to access a member and cannot find it. Methods.
In Example 6.14, __get and __set replace all access 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 with A certain prefix or a value containing a certain type. The
__call method describes 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 undefined method.
Listing 6.14 User-level overloading
class Overloader
{
private $properties = array(); {
$this-> ;properties[$property_name] = $value;
                                               ;



http://www.bkjia.com/PHPjc/445271.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/445271.html

TechArticle

Section 11 - Overloading PHP4 already has overloading syntax to establish external object models Mapping, just like Java and COM. PHP5 brings powerful object-oriented overloading, allowing programmers to build...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template