3v4l.org

run code in 300+ PHP versions simultaneously
<?php 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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Exception handler called: TypeError - explode(): Argument #1 ($separator) must be of type string, array given
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Error handler called: explode() expects parameter 1 to be string, array given Error handler called: explode() expects parameter 1 to be string, array given Caught exception: ParseError - syntax error, unexpected 'is' (T_STRING), expecting '(' Error handler called: Division by zero INFCaught exception: TypeError - Argument 1 passed to strict() must be of the type int, string given, called in /in/f2q5R on line 33
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
Error handler called: explode() expects parameter 1 to be string, array given Error handler called: explode() expects parameter 1 to be string, array given Caught exception: ParseError - syntax error, unexpected 'is' (T_STRING), expecting '(' Error handler called: Division by zero INFCaught exception: TypeError - Argument 1 passed to strict() must be of the type integer, string given, called in /in/f2q5R on line 33
Output for 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
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/f2q5R(21) : 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/f2q5R on line 33 and defined

preferences:
184.17 ms | 413 KiB | 5 Q