3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &foo() { $x = array(1,2,3); yield $x; echo "Gen: "; var_dump($x); return $x; } $rets = array(); $gen = foo(); foreach ($gen as &$val) { var_dump($val); $val[] = 42; $rets[] =& $val; } var_dump($gen->getReturn()); $rets[0][] = 100; var_dump($gen->getReturn());
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } Gen: array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(42) } array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(42) } array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(42) }

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