4.2. Overloading Capabilities

In PHP 5, extensions written in C can overload almost every aspect of the object syntax. It also allows PHP code to overload a limited subset that is most often needed. This section covers the overloading abilities that you can control from your PHP code.

4.2.1. Property and Method Overloading

PHP allows overloading of property access and method calls by implementing special proxy methods that are invoked if the relevant property or method doesn't exist. This gives you a lot of flexibility in intercepting these actions and defining your own functionality.

You may implement the following method prototypes:

function __get($property)
function __set($property, $value)
function __call($method, $args)

__get is passed ...

Get PHP 5 Power Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.