3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class foo { public function test($a, $b = 'test') { } } class bar extends foo { public function test($a, $b = 'test', $c = null) { } } class baz extends foo { public function test($a, $b = 'test', $c) { } } class bazbaz extends foo { public function test($a, $b = null, $c = null) { } } (new foo)->test(1, 2); (new bar)->test(1, 2); (new baz)->test(1, 2); (new bazbaz)->test(1, 2);
based on KIupu
Output for 7.1.0 - 7.2.0
Warning: Declaration of baz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/RmiOS on line 21 Fatal error: Uncaught ArgumentCountError: Too few arguments to function baz::test(), 2 passed in /in/RmiOS on line 35 and exactly 3 expected in /in/RmiOS:19 Stack trace: #0 /in/RmiOS(35): baz->test(1, 2) #1 {main} thrown in /in/RmiOS on line 19
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Declaration of baz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/RmiOS on line 21 Warning: Missing argument 3 for baz::test(), called in /in/RmiOS on line 35 and defined in /in/RmiOS on line 19
Output for 5.4.11 - 5.6.28
Strict Standards: Declaration of baz::test() should be compatible with foo::test($a, $b = 'test') in /in/RmiOS on line 21 Warning: Missing argument 3 for baz::test(), called in /in/RmiOS on line 35 and defined in /in/RmiOS on line 19
Output for 5.3.21 - 5.3.29
Strict Standards: Declaration of baz::test() should be compatible with that of foo::test() in /in/RmiOS on line 21 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/RmiOS on line 33
Process exited with code 255.