3v4l.org

run code in 300+ PHP versions simultaneously
<?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, $c) { } } (new foo)->test(1, 2); (new bar)->test(1, 2); (new baz)->test(1, 2); (new bazbaz)->test(1, 2);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Optional parameter $b declared before required parameter $c is implicitly treated as a required parameter in /in/jUkir on line 19 Fatal error: Declaration of baz::test($a, $b, $c) must be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 19
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Optional parameter $b declared before required parameter $c is implicitly treated as a required parameter in /in/jUkir on line 19 Fatal error: Declaration of baz::test($a, $b, $c) must be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 19
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Deprecated: Required parameter $c follows optional parameter $b in /in/jUkir on line 19 Fatal error: Declaration of baz::test($a, $b, $c) must be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 19
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of baz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 19 Warning: Declaration of bazbaz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 27 Fatal error: Uncaught ArgumentCountError: Too few arguments to function baz::test(), 2 passed in /in/jUkir on line 35 and exactly 3 expected in /in/jUkir:19 Stack trace: #0 /in/jUkir(35): baz->test(1, 2) #1 {main} thrown in /in/jUkir on line 19
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.5 - 7.2.33, 7.3.0 - 7.3.33
Warning: Declaration of baz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 21 Warning: Declaration of bazbaz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 29 Fatal error: Uncaught ArgumentCountError: Too few arguments to function baz::test(), 2 passed in /in/jUkir on line 35 and exactly 3 expected in /in/jUkir:19 Stack trace: #0 /in/jUkir(35): baz->test(1, 2) #1 {main} thrown in /in/jUkir 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/jUkir on line 21 Warning: Declaration of bazbaz::test($a, $b, $c) should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 29 Warning: Missing argument 3 for baz::test(), called in /in/jUkir on line 35 and defined in /in/jUkir on line 19 Warning: Missing argument 3 for bazbaz::test(), called in /in/jUkir on line 36 and defined in /in/jUkir on line 27
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of baz::test() should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 21 Strict Standards: Declaration of bazbaz::test() should be compatible with foo::test($a, $b = 'test') in /in/jUkir on line 29 Warning: Missing argument 3 for baz::test(), called in /in/jUkir on line 35 and defined in /in/jUkir on line 19 Warning: Missing argument 3 for bazbaz::test(), called in /in/jUkir on line 36 and defined in /in/jUkir on line 27

preferences:
172.26 ms | 402 KiB | 212 Q