3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $one = array( 1, 2, 3 ); $two = array( null ); $two[1] =& $one; var_dump( $two ); class foo { static function bar( &$v ) { var_dump( $v ); } } foo::bar( $two ); /* 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 */
based on FWJna
Output for 5.0.0 - 7.2.0
array(2) { [0]=> NULL [1]=> &array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } } array(2) { [0]=> NULL [1]=> &array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UdVsB on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UdVsB on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/UdVsB on line 10
Process exited with code 255.