3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = json_decode('[bar'); // many lines of code. $bar = json_encode('Hello world!', JSON_THROW_ON_ERROR); if (json_last_error() !== JSON_ERROR_NONE) { throw new Exception("encoding went wrong!"); } echo "All is fine";
Output for 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.6
Fatal error: Uncaught Exception: encoding went wrong! in /in/JJD5g:9 Stack trace: #0 {main} thrown in /in/JJD5g on line 9
Process exited with code 255.
Output for 7.2.0 - 7.2.34
Warning: Use of undefined constant JSON_THROW_ON_ERROR - assumed 'JSON_THROW_ON_ERROR' (this will throw an Error in a future version of PHP) in /in/JJD5g on line 7 Warning: json_encode() expects parameter 2 to be integer, string given in /in/JJD5g on line 7 Fatal error: Uncaught Exception: encoding went wrong! in /in/JJD5g:9 Stack trace: #0 {main} thrown in /in/JJD5g on line 9
Process exited with code 255.
Output for 7.1.0 - 7.1.33
Notice: Use of undefined constant JSON_THROW_ON_ERROR - assumed 'JSON_THROW_ON_ERROR' in /in/JJD5g on line 7 Warning: json_encode() expects parameter 2 to be integer, string given in /in/JJD5g on line 7 Fatal error: Uncaught Exception: encoding went wrong! in /in/JJD5g:9 Stack trace: #0 {main} thrown in /in/JJD5g on line 9
Process exited with code 255.

preferences:
235.76 ms | 402 KiB | 225 Q