3v4l.org

run code in 300+ PHP versions simultaneously
<?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(); foreach ($g as $val) { echo "$val\n"; }
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 Fatal error: Uncaught Exception: Cannot rewind a generator that was already run in /in/XdA5R:22 Stack trace: #0 {main} thrown in /in/XdA5R on line 22
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 2 3 21 22 23
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ',', expecting ']' in /in/XdA5R on line 10
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '[' in /in/XdA5R 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/XdA5R on line 4
Process exited with code 255.

preferences:
243.7 ms | 401 KiB | 375 Q