3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_call_user_func(callable $function, ...$args) { if (! is_array($function)) { return $function(...$args); } $object = reset($function); if (is_object($object)) { return Closure::bind(function () use ($args, $function) { return $function(...$args); }, $object, get_class($object))->__invoke(); } return $function(...$args); } class Test { private function foo() { echo new Exception; } public function callFoo($callfunc) { $callfunc(array($this, 'foo')); } } $o = new Test; $o->callFoo('call_user_func'); $o->callFoo('userland_call_user_func');
Output for git.master, git.master_jit, rfc.property-hooks
Exception in /in/SsAsJ:20 Stack trace: #0 [internal function]: Test->foo() #1 /in/SsAsJ(21): call_user_func(Array) #2 /in/SsAsJ(25): Test->callFoo('call_user_func') #3 {main} Fatal error: Uncaught TypeError: userland_call_user_func(): Argument #1 ($function) must be of type callable, array given, called in /in/SsAsJ on line 21 and defined in /in/SsAsJ:3 Stack trace: #0 /in/SsAsJ(21): userland_call_user_func(Array) #1 /in/SsAsJ(26): Test->callFoo('userland_call_u...') #2 {main} thrown in /in/SsAsJ on line 3
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.71 ms | 401 KiB | 8 Q