PHP has __call($name, array $args) . This is a catchall that handles situations where you call a method that is not specific to the instance.
In PHP> = 5.3, there is also __callStatic($name, array $args) , which acts basically the same way only at the class level (duh).
class MyClass { public function __call($name, array $args) { echo "You tried to call $name(".implode(',',$args)."). Silly user."; } } $k = new MyClass(); $k->doSomething(1,2,3);
The Java equivalent is a little more cumbersome, and it includes something called the Proxy class. The tutorial can be found here - examples are a little generalized here.
cwallenpoole
source share