3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen1() { echo "Beginning gen1\n"; $x = yield 1; echo "Sup!\n"; $y = yield 2; var_dump($x + $y); } function yfgenerator() { echo "Beginning yfgenerator\n"; yield from gen1(); echo "Dawg\n"; yield from gen1(); } function yfiterator() { yield from []; yield from [1, 2, 3]; /**/ yield from array( "first" => 1, "second" => 2, "third" => 3, ); /**/ } function iterationTest($g) { echo "About to start iteration\n"; foreach($g as $key => $val) { echo "Iteration!\n"; var_dump($key); var_dump($val); } echo "Done with iteration\n"; } function sendingTest($g) { $g->send(10); var_dump($g->current()); $g->send(20); var_dump($g->current()); } //iterationTest(yfiterator()); iterationTest(yfgenerator()); echo "====================\n"; //sendingTest(yfiterator()); sendingTest(yfgenerator()); echo "Done with all tests\n";
Output for git.master, git.master_jit, rfc.property-hooks
About to start iteration Beginning yfgenerator Beginning gen1 Iteration! int(0) int(1) Sup! Iteration! int(1) int(2) int(0) Dawg Beginning gen1 Iteration! int(0) int(1) Sup! Iteration! int(1) int(2) int(0) Done with iteration ==================== Beginning yfgenerator Beginning gen1 Sup! int(2) int(30) Dawg Beginning gen1 int(1) Done with all tests

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:
61.96 ms | 402 KiB | 8 Q