3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen() { $i = 0; $i = &$i; yield $i; var_dump($i); return $i; } $gen = gen(); var_dump($x = $gen->current()); $x++; var_dump($gen->next());
based on 5bA3a
Output for 7.0.0 - 7.2.0
int(0) int(0) NULL
Output for 5.5.24 - 5.6.28
Fatal error: Generators cannot return values using "return" in /in/bXJlN on line 11
Process exited with code 255.
Output for 5.4.2 - 5.4.45
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/bXJlN on line 7
Process exited with code 255.
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/bXJlN on line 7
Process exited with code 255.