3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function printer() { echo "I'm printer!".PHP_EOL; while (true) { $string = yield 'yielded'; echo $string.PHP_EOL; } } $printer = printer(); $printer->rewind(); var_dump($printer->current()); //$printer->send('Hello world!'); //$printer->send('Bye world!'); ?>
based on kjrYm
Output for hhvm-3.15.4, 7.0.0 - 7.2.6
I'm printer! string(7) "yielded"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ''yielded'' (T_CONSTANT_ENCAPSED_STRING) in /in/1btbv on line 5
Process exited with code 255.