3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_call_user_func($function, ...$args) { $class = isset(debug_backtrace()[1]['class']) ? debug_backtrace()[1]['class'] : null; return Closure::bind(function () use ($args, $function) { return $function(...$args); }, null, $class)->__invoke(); } class Test1 { private function foo() { echo new Exception; } public function callFoo($callfunc) { $new=new Test2; $callfunc(array($new, 'foo')); } } class Test2 { private function foo() { echo new Exception; } } $o = new Test1; $o->callFoo('userland_call_user_func'); $o->callFoo('call_user_func');
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to private method Test2::foo() from scope Test1 in /in/6IKKl:7 Stack trace: #0 /in/6IKKl(8): Test1::{closure}() #1 /in/6IKKl(8): Closure->__invoke() #2 /in/6IKKl(13): userland_call_user_func(Array) #3 /in/6IKKl(21): Test1->callFoo('userland_call_u...') #4 {main} thrown in /in/6IKKl on line 7
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:
41.79 ms | 401 KiB | 8 Q