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()); }
based on li8a2
Output for 8.0.0 - 8.0.3
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.27, 7.4.0 - 7.4.16
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