3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function & retRef() { global $foo; return $foo; } // don't assign by reference doesn't result in a reference $foo = 'init'; $bar = retRef(); $bar = 'bar'; var_dump($foo, $bar); // reset variables unset($foo, $bar); // requires to assign the function call by reference $foo = 'init'; $bar = & retRef(); $bar = 'bar'; var_dump($foo, $bar);
Output for 4.3.0 - 7.1.0
string(4) "init" string(3) "bar" string(3) "bar" string(3) "bar"