3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_call_user_func($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/QuQM1:20 Stack trace: #0 [internal function]: Test->foo() #1 /in/QuQM1(21): call_user_func(Array) #2 /in/QuQM1(25): Test->callFoo('call_user_func') #3 {main}Exception in /in/QuQM1:20 Stack trace: #0 /in/QuQM1(12): Test->foo() #1 /in/QuQM1(13): Test->{closure}() #2 /in/QuQM1(13): Closure->__invoke() #3 /in/QuQM1(21): userland_call_user_func(Array) #4 /in/QuQM1(26): Test->callFoo('userland_call_u...') #5 {main}

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:
38.15 ms | 402 KiB | 8 Q