3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Foo { public function test(string $value); } abstract class Fan implements Foo { abstract public function test(string $value); public function otherTest(string $value) { var_dump(__METHOD__, $value); } } class Bar extends Fan implements Foo { public function test(string $value) { var_dump(__METHOD__, $value); } } class Baz extends Bar {} class Bop extends Bar { public function test(string $value) { var_dump(__METHOD__, $value); } } class Fin extends Fan { public function test(string $value) { var_dump(__METHOD__, $value); } } $bar = new Bar(); $baz = new Baz(); $bop = new Bop(); $fin = new Fin(); $bar->test('bar'); $bar->otherTest('bar'); $bar->test('baz'); $bar->otherTest('bar'); $bop->test('bop'); $bop->otherTest('bop'); $fin->test('fan'); $fin->otherTest('fan');
Output for 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.18, 8.3.0 - 8.3.4, 8.3.6
string(9) "Bar::test" string(3) "bar" string(14) "Fan::otherTest" string(3) "bar" string(9) "Bar::test" string(3) "baz" string(14) "Fan::otherTest" string(3) "bar" string(9) "Bop::test" string(3) "bop" string(14) "Fan::otherTest" string(3) "bop" string(9) "Fin::test" string(3) "fan" string(14) "Fan::otherTest" string(3) "fan"
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 string(9) "Bar::test" string(3) "bar" string(14) "Fan::otherTest" string(3) "bar" string(9) "Bar::test" string(3) "baz" string(14) "Fan::otherTest" string(3) "bar" string(9) "Bop::test" string(3) "bop" string(14) "Fan::otherTest" string(3) "bop" string(9) "Fin::test" string(3) "fan" string(14) "Fan::otherTest" string(3) "fan"

preferences:
346.1 ms | 402 KiB | 182 Q