3v4l.org

run code in 300+ PHP versions simultaneously
<?php spl_autoload_register(function () { var_dump(func_get_args()); }); try { new Foo(); } catch(Throwable $t) { var_dump($t); } if (true) { class Foo {} var_dump(new Foo()); }
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
array(1) { [0]=> string(3) "Foo" } object(Error)#2 (7) { ["message":protected]=> string(21) "Class "Foo" not found" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/iSXM2" ["line":protected]=> int(8) ["trace":"Error":private]=> array(0) { } ["previous":"Error":private]=> NULL } object(Foo)#3 (0) { }
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 array(1) { [0]=> string(3) "Foo" } object(Error)#2 (7) { ["message":protected]=> string(21) "Class "Foo" not found" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/iSXM2" ["line":protected]=> int(8) ["trace":"Error":private]=> array(0) { } ["previous":"Error":private]=> NULL } object(Foo)#3 (0) { }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
array(1) { [0]=> string(3) "Foo" } object(Error)#2 (7) { ["message":protected]=> string(21) "Class 'Foo' not found" ["string":"Error":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/iSXM2" ["line":protected]=> int(8) ["trace":"Error":private]=> array(0) { } ["previous":"Error":private]=> NULL } object(Foo)#3 (0) { }

preferences:
134.89 ms | 402 KiB | 156 Q