3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen1() { yield 1; yield 2; yield 3; } function gen2(bool $opt) { if ($opt) return gen1(); yield 4; yield 5; yield 6; } print_r(iterator_to_array(gen2(true))); print_r(iterator_to_array(gen2(false)));
Output for hhvm-3.15.4, 7.0.0 - 7.3.0rc3
Array ( ) Array ( [0] => 4 [1] => 5 [2] => 6 )
Output for 5.6.0 - 5.6.30
Fatal error: Generators cannot return values using "return" in /in/oXhYu on line 13
Process exited with code 255.