3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( 0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine' ); foreach ($array as $key => $value) { try { if ($key === 2) { throw new Exception("Key 2 Exception ({$value})"); } echo $value . "\n"; } catch (Exception $e) { echo $e->getMessage() . "\n"; } }
Output for 5.0.0 - 7.2.0
zero one Key 2 Exception (two) three four five six seven eight nine
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/4mfb5 on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/4mfb5 on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4mfb5 on line 17
Process exited with code 255.