3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); set_error_handler(function ($n, $message) { echo 'Error handler called: ' . $message . PHP_EOL; }); set_exception_handler(function ($e) { echo 'Exception handler called: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL; }); function strict(int $i) {} explode(['not', 'valid'], ['arguments']); try { explode(['not', 'valid'], ['arguments']); } catch (Throwable $e) { echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL; } try { eval('eval is evil'); } catch (ParseError $e) { echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL; } try { echo 1 / 0; } catch (DivisionByZeroError $e) { echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL; } try { strict('one'); } catch (TypeError $e) { echo 'Caught exception: ' . get_class($e) . ' - ' . $e->getMessage() . PHP_EOL; }
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
Exception handler called: TypeError - explode(): Argument #1 ($separator) must be of type string, array given
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 Exception handler called: TypeError - explode(): Argument #1 ($separator) must be of type string, array given
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Exception handler called: TypeError - explode() expects parameter 1 to be string, array given
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/RNKXa on line 3 Error handler called: explode() expects parameter 1 to be string, array given Error handler called: explode() expects parameter 1 to be string, array given Parse error: syntax error, unexpected 'is' (T_STRING), expecting '(' in /in/RNKXa(23) : eval()'d code on line 1 Error handler called: Division by zero Error handler called: Argument 1 passed to strict() must be an instance of int, string given, called in /in/RNKXa on line 35 and defined

preferences:
186.39 ms | 403 KiB | 217 Q