3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $params = [1,2,3]; function transform(array &$params) { $references = []; foreach ($params as &$value) { $references[] = &$value; } $value = "foo"; return $references; } var_dump($params); $p = transform($params); var_dump($p); debug_zval_dump($p); debug_zval_dump($params);
based on k531S
Output for 7.0.0 - 7.1.0, 7.1.7 - 7.2.0
array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(3) { [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" } array(3) refcount(2){ [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" refcount(1) } array(3) refcount(2){ [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" refcount(1) }
Output for 7.1.5 - 7.1.6
array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(3) { [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" } array(3) refcount(2){ [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" refcount(2) } array(3) refcount(2){ [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" refcount(2) }
Output for 5.4.9 - 5.6.28
array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(3) { [0]=> &int(1) [1]=> &int(2) [2]=> &string(3) "foo" } array(3) refcount(2){ [0]=> &long(1) refcount(2) [1]=> &long(2) refcount(2) [2]=> &string(3) "foo" refcount(2) } array(3) refcount(2){ [0]=> &long(1) refcount(2) [1]=> &long(2) refcount(2) [2]=> &string(3) "foo" refcount(2) }
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/MAChh on line 3
Process exited with code 255.