3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function printer() { $string = yield; return; } $printer = printer(); $printer->send('Hello world!'); foreach ($printer as $greeting) { echo $greeting; } ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/kHv9h:9 Stack trace: #0 {main} thrown in /in/kHv9h on line 9
Process exited with code 255.
Output for hhvm-3.12.0
Output for hhvm-3.10.0
Fatal error: Uncaught exception 'Exception' with message 'Need to call next() first' in /in/kHv9h:8 Stack trace: #0 /in/kHv9h(8): Generator->send() #1 {main}
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'Cannot traverse an already closed generator' in /in/kHv9h:9 Stack trace: #0 /in/kHv9h(9): unknown() #1 {main} thrown in /in/kHv9h on line 9
Process exited with code 255.
Output for 5.0.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/kHv9h on line 3 Fatal error: Call to a member function send() on a non-object in /in/kHv9h on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Use of undefined constant yield - assumed 'yield' in /in/kHv9h on line 3 Fatal error: Call to a member function on a non-object in /in/kHv9h on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant yield - assumed 'yield' in /in/kHv9h on line 3 Fatal error: Call to a member function on a non-object in /in/kHv9h on line 8