3v4l.org

run code in 500+ PHP versions simultaneously
<?php set_exception_handler(function (\Throwable $exception) { echo 'Caught: ' . $exception->getMessage() . "\n"; }); set_error_handler(static function (int $severity, string $msg, string $file, int $line): bool { if ((error_reporting() & ~(\PHP_MAJOR_VERSION >= 8 ? 4437 : 0)) === 0) { return false; } echo 'Caught error: ' . $msg . "\n"; return true; }); register_shutdown_function(function () { trigger_error('warn_shutdown_1', \E_USER_WARNING); }); register_shutdown_function(function () { trigger_error('warn_shutdown_2', \E_USER_WARNING); }); register_shutdown_function(function () { throw new \Exception('ex_shutdown_1'); }); register_shutdown_function(function () { // expected to be never executed as after 1 uncaught exception php invokes shutdown, // after 1 uncaught exception in shutdown, php terminates throw new \Exception('ex_shutdown_2'); }); trigger_error('warn_regular_1', \E_USER_WARNING); trigger_error('warn_regular_2', \E_USER_WARNING); throw new \Exception('ex_regular');
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.4
Caught error: warn_regular_1 Caught error: warn_regular_2 Caught: ex_regular Caught error: warn_shutdown_1 Caught error: warn_shutdown_2 Fatal error: Uncaught Exception: ex_shutdown_1 in /in/lXRcY:24 Stack trace: #0 [internal function]: {closure}() #1 {main} thrown in /in/lXRcY on line 24
Process exited with code 255.
Output for 8.3.5 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
Caught error: warn_regular_1 Caught error: warn_regular_2 Caught: ex_regular Caught error: warn_shutdown_1 Caught error: warn_shutdown_2 Caught: ex_shutdown_1 Caught: ex_shutdown_2

preferences:
38.05 ms | 1155 KiB | 9 Q