3v4l.org

run code in 300+ PHP versions simultaneously
<?php function nums() { for ($i = 0; $i < 5; ++$i) { echo "aa".$i; //get a value from the caller $cmd = (yield $i); var_dump('cmd', $cmd); if($cmd == 'stop') { //exit the function } } } $gen = nums(); foreach($gen as $v) { if($v == 3) { $send = $gen->send('stop'); var_dump("send ",$send); } //if (isset($send)) var_dump($send); echo "--{$v}\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
aa0--0 string(3) "cmd" NULL aa1--1 string(3) "cmd" NULL aa2--2 string(3) "cmd" NULL aa3string(3) "cmd" string(4) "stop" aa4string(5) "send " int(4) --3 string(3) "cmd" 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:
46.42 ms | 401 KiB | 8 Q