3v4l.org

run code in 300+ PHP versions simultaneously
<?php $callable = fn() => throw new Exception(); // $value is non-nullable. // $value = $nullableValue ?? throw new InvalidArgumentException(); // $value is truthy. $value = $falsableValue ?: throw new InvalidArgumentException(); // $value is only set if the array is not empty. $value = !empty($array) ? reset($array) : throw new InvalidArgumentException();
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Undefined variable $falsableValue in /in/SbcpPR on line 9 Fatal error: Uncaught InvalidArgumentException in /in/SbcpPR:9 Stack trace: #0 {main} thrown in /in/SbcpPR on line 9
Process exited with code 255.
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 Warning: Undefined variable $falsableValue in /in/SbcpPR on line 9 Fatal error: Uncaught InvalidArgumentException in /in/SbcpPR:9 Stack trace: #0 {main} thrown in /in/SbcpPR on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.5
Parse error: syntax error, unexpected 'throw' (T_THROW) in /in/SbcpPR on line 3
Process exited with code 255.
Output for 7.2.0 - 7.2.29, 7.3.0 - 7.3.17
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/SbcpPR on line 3
Process exited with code 255.

preferences:
115.33 ms | 402 KiB | 81 Q