3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { public function foo($arg1, $arg2, $arg3) { var_dump($arg1, $arg2); } } class B extends A { public function foo($arg1, $arg2, $arg3) { call_user_func_array(['parent', 'foo'], [3] + [$arg2, $arg1]); } } $b = new B; $b->foo(1, 2, 4);
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function A::foo(), 2 passed in /in/agNEM on line 15 and exactly 3 expected in /in/agNEM:5 Stack trace: #0 /in/agNEM(15): A->foo(3, 1) #1 /in/agNEM(20): B->foo(1, 2, 4) #2 {main} thrown in /in/agNEM on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Warning: Missing argument 3 for A::foo(), called in /in/agNEM on line 15 and defined in /in/agNEM on line 5 int(3) int(1)
Output for hhvm-3.10.0 - 3.12.0
Warning: foo() expects exactly 3 parameters, 2 given in /in/agNEM on line 7 int(3) int(1)
Output for 5.4.0 - 5.6.28
Warning: Missing argument 3 for A::foo() in /in/agNEM on line 5 int(3) int(1)
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/agNEM on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[', expecting ')' in /in/agNEM on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/agNEM on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/agNEM on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/agNEM on line 5
Process exited with code 255.