3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $t = array(1,2,3); foreach($t as $k => $val) { try { if($val == 2) { throw new Exception('stop '.$k); } echo $k.' '.$val."\r\n"; } catch(Exception $e) { echo $e->getMessage()."\r\n--\r\n"; } }
based on lluIE
Output for 5.0.0 - 7.2.0
0 1 stop 1 -- 2 3
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/UvUE4 on line 4
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/UvUE4 on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/UvUE4 on line 4
Process exited with code 255.