3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function count_to_ten() { $t = yield; echo '$'.($t); yield from seven_eight(); return 'ok'; } function seven_eight() { foreach ([1, 2, 3] as $k => $v) { yield $v; } } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo "\n-$k -> $num \n";echo $gen->send('t'); } var_dump( $gen->getReturn());
based on RUKAv
Output for 7.0.0 - 7.3.0rc3
-0 -> $t1 -1 -> 2 3string(2) "ok"
Output for hhvm-3.15.4
-0 -> $t -1 -> 2 string(2) "ok"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'seven_eight' (T_STRING) in /in/43Huc on line 7
Process exited with code 255.