3v4l.org

run code in 300+ PHP versions simultaneously
<?php try { 10 / 0; } catch (\DivisionByZeroError $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); } try { $null->var = false; } catch (\Error $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); } try { $i = 100; $i[] = 'd'; } catch (\Error $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); } try { [''][new stdClass]; } catch (\TypeError $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); } try { $s = 'abc'; $s[''] = 'd'; } catch (\TypeError $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); } try { echo UNDEF_CONST; } catch (\Error $e) { printf("%d: %s\n", __LINE__, $e->getMessage()); }
Output for 8.3.0 - 8.3.4, 8.3.6
2: Division by zero 3: Attempt to assign property "var" on null 4: Cannot use a scalar value as an array 5: Cannot access offset of type stdClass on array 6: Cannot access offset of type string on string 7: Undefined constant "UNDEF_CONST"
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 2: Division by zero 3: Attempt to assign property "var" on null 4: Cannot use a scalar value as an array 5: Cannot access offset of type stdClass on array 6: Cannot access offset of type string on string 7: Undefined constant "UNDEF_CONST"
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
2: Division by zero 3: Attempt to assign property "var" on null 4: Cannot use a scalar value as an array 5: Illegal offset type 6: Cannot access offset of type string on string 7: Undefined constant "UNDEF_CONST"
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Division by zero in /in/G3MWC on line 2 Warning: Creating default object from empty value in /in/G3MWC on line 3 Warning: Cannot use a scalar value as an array in /in/G3MWC on line 4 Warning: Illegal offset type in /in/G3MWC on line 5 Warning: Illegal string offset '' in /in/G3MWC on line 6 Warning: Use of undefined constant UNDEF_CONST - assumed 'UNDEF_CONST' (this will throw an Error in a future version of PHP) in /in/G3MWC on line 7 UNDEF_CONST

preferences:
170.18 ms | 402 KiB | 153 Q