3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function generate_ints($n){ foreach ( range(0,$n-1) as $number) { $number = (yield $number): yield $number; } } $gen = generate_ints(3); echo $gen->current(); $gen->next(); echo $gen->current(); $gen->send(1); // injecting a value; echo $gen->current(); $gen->next(); echo $gen->current(); $gen->next(); echo $gen->current();
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$number' (T_VARIABLE) in /in/U3kSY on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/U3kSY on line 5
Process exited with code 255.