3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Toto { public function yieldData() { yield 0 => 'a'; return 'd'; yield 0 => 'b'; yield 0 => 'c'; } public function getData() { return [ 'a', 'b', 'c', ]; } } $toto = new Toto(); foreach ($toto->yieldData() as $i => $data) { var_dump($i, $data); }
based on hNHnA
Output for hhvm-3.18.4 - 3.21.0, 7.0.0 - 7.3.0beta1
int(0) string(1) "a"
Output for 5.6.0 - 5.6.30
Fatal error: Generators cannot return values using "return" in /in/Io7Wi on line 9
Process exited with code 255.