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() { foreach ([1, 2, 3] as $k => $v) { $k = yield $v; echo '#'; var_dump($k); } } $gen = count_to_ten(); foreach ($gen as $k => $num) { echo $gen->send('t'); echo "\n-$k -> $num \n"; } var_dump( $gen->getReturn());
based on YLCAb
Output for 7.0.0 - 7.1.7
#string(1) "t" 2 -0 -> 1 #NULL #string(1) "t" NULL $ -2 -> 3 string(2) "ok"
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_YIELD_FROM in /in/2lZkJ:5 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected 'seven_eight' (T_STRING) in /in/2lZkJ on line 5
Process exited with code 255.