class Magic { function __call($name,$arguments) { if($name=='foo') { if(is_int($arguments[0])) $this->foo_for_int($arguments[0]); if(is_string($arguments[0])) $this->foo_for_string($arguments[0]); } } private function foo_for_int($x) { print("oh an int!"); } private function foo_for_string($x) { print("oh a string!"); } } $x = new Magic(); $x->foo(3); $x->foo("3"); die;
class Magic { function __call($name,$arguments) { //var_dump($name,$arguments); $name = '_'.$name; $this->$name($arguments[0],$arguments[1]); //if(is_string($arguments[0])) $this->foo_for_string($arguments[0]); } private function _foo_for_int($x,$y) { print("oh an int!"); } private function foo_for_string($x) { print("oh a string!"); } } $x = new Magic(); $x->foo_for_int(3,'ohjkn');