3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function fun($bar) { echo "fooo" . $bar; } } $parts = ['Foo', 'fun']; $controller = array_shift($parts); $method = array_shift($parts); call_user_func_array([new $controller, $method], $parts);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Foo::fun(), 0 passed in /in/M3KTQ on line 13 and exactly 1 expected in /in/M3KTQ:4 Stack trace: #0 /in/M3KTQ(13): Foo->fun() #1 {main} thrown in /in/M3KTQ on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Warning: Missing argument 1 for Foo::fun(), called in /in/M3KTQ on line 13 and defined in /in/M3KTQ on line 4 Notice: Undefined variable: bar in /in/M3KTQ on line 5 fooo
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Warning: Missing argument 1 for Foo::fun() in /in/M3KTQ on line 4 Notice: Undefined variable: bar in /in/M3KTQ on line 5 fooo

preferences:
225.45 ms | 402 KiB | 378 Q