3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __call($name, $args) { $hash = join('_', array_map('gettype')); if(method_exists($this, $name.$hash)) { return call_user_func_array([$this, $name.$hash], $args); } } protected function foo_int_string($x, $y) { echo('Called method implementation with 1-st (int) and 2-nd (string) parameters'.PHP_EOL); } protected function foo_int_int($x, $y) { echo('Called method implementation with 1-st (int) and 2-nd (int) parameters'.PHP_EOL); } } $obj=new Test(); $obj->foo(5, "bar"); $obj->foo(8, 2);

preferences:
48.71 ms | 402 KiB | 5 Q