3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $gen = (function () { yield from range('a', 'z'); })(); $c = 0; foreach ($gen as $k => $v) { echo $v . PHP_EOL; if ($c > 2) { break; } } foreach ($gen as $k => $v) { echo $v . PHP_EOL; break; }
based on N9JmU
Output for 7.0.0 - 7.3.0rc3
a b c d e f g h i j k l m n o p q r s t u v w x y z Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/7pYM3:13 Stack trace: #0 {main} thrown in /in/7pYM3 on line 13
Process exited with code 255.
Output for hhvm-3.15.4
a b c d e f g h i j k l m n o p q r s t u v w x y z
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'range' (T_STRING) in /in/7pYM3 on line 3
Process exited with code 255.