3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { $x = yield 1; echo "Got $x from a yield\n"; $x = yield 2; echo "Got $x from a yield\n"; $x = yield 3; echo "Got $x from a yield\n"; } function yf($iter) { yield from $iter; } function yfr($iter) { $isSubgenerator = $iter instanceof Generator; foreach($iter as $val) { yield $val; } } // $g = yfr(gen1()); $g = yf(gen1()); $g->next(); var_dump($g->current()); $g->send(10); var_dump($g->current()); $g->send(20); var_dump($g->current());
Output for git.master, git.master_jit, rfc.property-hooks
Got from a yield int(2) Got 10 from a yield int(3) Got 20 from a yield NULL

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:
55.13 ms | 401 KiB | 8 Q