3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen($a = 0) { yield 1; yield 2; yield 3; yield 4; yield 5; } function bar($gen) { yield from $gen; } $gen = gen(); $gens[] = bar($gen); $gens[] = bar($gen); do { foreach ($gens as $g) { echo "Current: "; var_dump($g->current()); // Notice - We are advancing the underlying gen, not either of the things // gens in the array. If we delegate properly, then our other generators // should be implicitly advancing as well. $gen->next(); } } while($gen->valid()); var_dump($gens[1]->valid());
Output for git.master, git.master_jit, rfc.property-hooks
Current: int(1) Current: int(2) Current: int(3) Current: int(4) Current: int(5) Current: int(5) bool(true)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.28 ms | 401 KiB | 8 Q