3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = ['item', '2']; $b = (function () use ($a) { foreach ($a as $item) { yield $item; } })(); while ($b->valid()) { var_dump($b->current()); $b->next(); }
based on i1sQt
Output for hhvm-3.15.4, 7.0.0 - 7.3.0rc3
string(4) "item" string(1) "2"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/1j783 on line 9
Process exited with code 255.