Using the __call() Method : __call « Class « PHP






Using the __call() Method

 
<?php
     class ParentClass {
          function __call($method, $params) {
               echo "The method $method doesn't exist!\n";
          }
     }
     class ChildClass extends ParentClass {
          function myFunction() {
          }
     }
     $inst = new ChildClass();
     $inst->nonExistentFunction();
?>
  
  








Related examples in the same category

1.__call( ) method is called if PHP fails to find the method
2.Intercepting Method Calls with the __call() Method (PHP 5 Only)