3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $hello; public function __construct() { $this->hello = function(){ echo 'hello from callable'; }; } public function hello() { echo 'hello from object'; } public function __call($method, $args) { if(is_callable(array($this, $method))) { return call_user_func_array($this->$method, $args); } } } $foo = new Foo(); $foo->hello(); call_user_func($foo->hello);

preferences:
29.93 ms | 402 KiB | 5 Q