3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function func(&$arraykey) { return $arraykey; // function returns by value! } $array = array('a', 'b', 'c'); foreach (array_keys($array) as $key) { $y = &func($array[$key]); $z[] =& $y; } var_dump($z); ?>
Output for 4.4.0 - 4.4.9, 7.0.0 - 7.1.0
Notice: Only variables should be assigned by reference in /in/qeRCf on line 8 Notice: Only variables should be assigned by reference in /in/qeRCf on line 8 Notice: Only variables should be assigned by reference in /in/qeRCf on line 8 array(3) { [0]=> &string(1) "c" [1]=> &string(1) "c" [2]=> &string(1) "c" }
Output for hhvm-3.10.0 - 3.12.0
array(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> &string(1) "c" }
Output for 5.0.5 - 5.6.28
Strict Standards: Only variables should be assigned by reference in /in/qeRCf on line 8 Strict Standards: Only variables should be assigned by reference in /in/qeRCf on line 8 Strict Standards: Only variables should be assigned by reference in /in/qeRCf on line 8 array(3) { [0]=> &string(1) "c" [1]=> &string(1) "c" [2]=> &string(1) "c" }
Output for 4.3.0 - 4.3.11, 5.0.0 - 5.0.4
array(3) { [0]=> &string(1) "a" [1]=> &string(1) "b" [2]=> &string(1) "c" }