3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function gen_one_to_three() { for ($i = 1; $i <= 3; $i++) { $a = yield; echo $a; } } $generator = gen_one_to_three(); foreach ($generator as $value) { var_dump($value); }
Output for 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
NULL NULL NULL
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield Warning: Invalid argument supplied for foreach() in /in/EPhoc on line 12
Output for 4.3.11
Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield Notice: Use of undefined constant yield - assumed 'yield' in /in/EPhoc on line 6 yield