3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function toto(): \Generator { yield 0 => '1'; yield 0 => '2'; yield 1 => '3'; } var_dump(toto()); foreach (toto() as $k => $toto) { var_dump($k); var_dump($toto); }
based on 6DlhH
Output for 7.0.28 - 7.3.0rc3
object(Generator)#1 (0) { } int(0) string(1) "1" int(0) string(1) "2" int(1) string(1) "3"
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting '{' in /in/H0lgR on line 3
Process exited with code 255.