@ 2015-10-13T22:09:40Z <?php
function gen1() {
yield 11;
yield 12;
yield 13;
}
function gen2() {
yield from [1, 2, 3];
yield 21;
yield 22;
yield 23;
}
$g = gen2();
$c = $g->current();
echo "C: $c\n";
$g->next();
$c = $g->current();
echo "C: $c\n";
foreach ($g as $val) { echo "$val\n"; }
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 C: 1
C: 2
Fatal error: Uncaught Exception: Cannot rewind a generator that was already run in /in/QsnP3:24
Stack trace:
#0 {main}
thrown in /in/QsnP3 on line 24
Process exited with code 255 . Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 C: 1
C: 2
2
3
21
22
23
Output for 5.6.0 - 5.6.40 Parse error: syntax error, unexpected ',', expecting ']' in /in/QsnP3 on line 10
Process exited with code 255 . Output for 5.5.0 - 5.5.38 Parse error: syntax error, unexpected '[' in /in/QsnP3 on line 10
Process exited with code 255 . Output for 5.4.0 - 5.4.45 Parse error: syntax error, unexpected '11' (T_LNUMBER) in /in/QsnP3 on line 4
Process exited with code 255 . preferences:dark mode live preview
279.99 ms | 401 KiB | 373 Q