3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function something($param1, $param2 = array()) { var_dump($param1, $param2); } } class Bar extends Foo { public function something($param1, $param2, $param3) { return parent::something($param1, $param2); } } $test = new Bar(); $test->something('param111');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Declaration of Bar::something($param1, $param2, $param3) must be compatible with Foo::something($param1, $param2 = []) in /in/N480h on line 13
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 Fatal error: Declaration of Bar::something($param1, $param2, $param3) must be compatible with Foo::something($param1, $param2 = []) in /in/N480h on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of Bar::something($param1, $param2, $param3) should be compatible with Foo::something($param1, $param2 = Array) in /in/N480h on line 13 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Bar::something(), 1 passed in /in/N480h on line 20 and exactly 3 expected in /in/N480h:13 Stack trace: #0 /in/N480h(20): Bar->something('param111') #1 {main} thrown in /in/N480h on line 13
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Warning: Declaration of Bar::something($param1, $param2, $param3) should be compatible with Foo::something($param1, $param2 = Array) in /in/N480h on line 17 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Bar::something(), 1 passed in /in/N480h on line 20 and exactly 3 expected in /in/N480h:13 Stack trace: #0 /in/N480h(20): Bar->something('param111') #1 {main} thrown in /in/N480h on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Warning: Declaration of Bar::something($param1, $param2, $param3) should be compatible with Foo::something($param1, $param2 = Array) in /in/N480h on line 17 Warning: Missing argument 2 for Bar::something(), called in /in/N480h on line 20 and defined in /in/N480h on line 13 Warning: Missing argument 3 for Bar::something(), called in /in/N480h on line 20 and defined in /in/N480h on line 13 Notice: Undefined variable: param2 in /in/N480h on line 15 string(8) "param111" NULL
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Strict Standards: Declaration of Bar::something() should be compatible with Foo::something($param1, $param2 = Array) in /in/N480h on line 17 Warning: Missing argument 2 for Bar::something(), called in /in/N480h on line 20 and defined in /in/N480h on line 13 Warning: Missing argument 3 for Bar::something(), called in /in/N480h on line 20 and defined in /in/N480h on line 13 Notice: Undefined variable: param2 in /in/N480h on line 15 string(8) "param111" NULL

preferences:
194.68 ms | 402 KiB | 294 Q