3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function xrange() { for ($i = 0; $i < 1000; $i++) { yield $i; } } $range = xrange(); echo "first"; foreach ($range as $i) {} echo "second"; foreach ($range as $i) {}
Output for 7.0.0 - 7.3.0rc3
firstsecond Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/c5ZgC:13 Stack trace: #0 {main} thrown in /in/c5ZgC on line 13
Process exited with code 255.
Output for hhvm-3.15.4
firstsecond
Output for 5.6.0 - 5.6.30
firstsecond Fatal error: Uncaught exception 'Exception' with message 'Cannot traverse an already closed generator' in /in/c5ZgC:13 Stack trace: #0 /in/c5ZgC(13): unknown() #1 {main} thrown in /in/c5ZgC on line 13
Process exited with code 255.