3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { static $mem; static function setMem( &$v ) { self::$mem[ $v[0] ] = $v[1]; } static function readMem( &$v ) { $a = $v[3]; $v[2][$a] =& self::$mem[ $v[1] ]; } static function reset( &$v ) { reset( $v[0] ); } static function each( &$v ) { var_dump( $v ); $t = each( $v[0] ); self::$mem[ $v[1] ] = $t[1]; } static function show( &$v ) { echo $v[0]; } } $reset = array(null); $each = array(null, 'new'); $show = array(null); $arr = array( array('variable', array(1, 2, 3) ), array( 1=>'variable', 3=>0 ), array(), array( 1=>'variable', 3=>0 ), $each, array( 1=>'new', 3=>0 ),// 5 $show, ); $arr[1][2] =& $reset; $arr[2][0] =& $reset; $arr[3][2] =& $each; $arr[5][2] =& $show; $n = 0; foo::setMem( $arr[$n++] ); // 0 foo::readMem( $arr[$n++] ); // 1 foo::reset( $arr[$n++] ); // 2 foo::readMem( $arr[$n++] ); // 3 var_dump( $each ); foo::each( $arr[$n++] ); // 4 foo::readMem( $arr[$n++] ); // 5 foo::show( $arr[$n++] ); // 6
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> &array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } [1]=> string(3) "new" } array(2) { [0]=> NULL [1]=> string(3) "new" } Fatal error: Uncaught Error: Call to undefined function each() in /in/FWJna:21 Stack trace: #0 /in/FWJna(55): foo::each(Array) #1 {main} thrown in /in/FWJna on line 21
Process exited with code 255.

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