Intercepting Calls to Object Properties and Methods
PHP 5 introduces three built-in methods that you can use to trap messages to your objects and alter default behavior.
Usually, if an undefined method is called, a fatal error will be generated and your script will fail. If you define a __call() method in your class, however, you can catch the message and decide what to do with it. Every time an undeclared method is called on your object, the __call() method will be invoked. Two arguments will automatically be populated for you: a string variable holding the name of the method that was called and an array variable holding any arguments that were passed. Anything you return from __call() is returned to the client code as if the undefined method ...
Get Sams Teach Yourself PHP in 24 Hours, Third Edition 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.