3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function count_to_ten() { $t = (yield from seven_eight()); echo '$'.var_dump($t); return 'ok'; } function seven_eight() { $k = yield;echo '#'; var_dump($k); foreach ([1, 2, 3] as $k => $v) { yield $v; } } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo $gen->send('t'); echo "\n-$k -> $num \n"; } var_dump( $gen->getReturn());
based on 2lZkJ
Output for 7.0.0 - 7.3.1
#string(1) "t" 1 -0 -> 3 -2 -> 2 NULL $string(2) "ok"
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_YIELD_FROM in /in/PtmAD:5 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.38
Parse error: syntax error, unexpected 'seven_eight' (T_STRING) in /in/PtmAD on line 5
Process exited with code 255.