|
Both method calls and member accesses can be overloaded via the __call, __get and __set methods. These methods will only be triggered when your object or inherited object doesn't contain the member or method you're trying to access. All overloading methods must be defined as public.
Class members can be overloaded to run custom code defined in your class by defining these specially named methods. The $name parameter used is the name of the variable that should be set or retrieved. The __set() method's $value parameter specifies the value that the object should set the $name.
Class methods can be overloaded to run custom code defined in your class by defining this specially named method. The $name parameter used is the name as the function name that was requested to be used. The arguments that were passed in the function will be defined as an array in the $arguments parameter. The value returned from the __call() method will be returned to the caller of the method.
Beispiel 19-19. overloading with __call example
Das oben gezeigte Beispiel erzeugt folgende Ausgabe:
|
Zurück | Zum Anfang | Weiter |
Object Interfaces | Nach oben | Object Iteration |
Hosting by: Hurra Communications GmbH
Generated: 2007-01-26 17:57:10