3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { for ($i = 0; $i < 5; ++$i) { //get a value from the caller $cmd = (yield $i); var_dump($cmd); if($cmd == 'stop') { return;//exit the function } } } $gen = nums(); foreach($gen as $v) { if($v == 3) { $send = $gen->send('stop'); } if (isset($send)) var_dump($send); echo "{$v}\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
0 NULL 1 NULL 2 NULL string(4) "stop" 3

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