3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function retVal() { global $foo; return $foo; } function & retRef() { global $foo; return $foo; } unset($foo, $bar); $foo = 'init'; $bar = retVal(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $foo = 'init'; $bar = retRef(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $foo = 'init'; $bar = & retVal(); $bar = 'bar'; var_dump($foo, $bar); unset($foo, $bar); $foo = 'init'; $bar = & retRef(); $bar = 'bar'; var_dump($foo, $bar);
Output for 4.4.0 - 4.4.9, 7.0.0 - 7.1.0
string(4) "init" string(3) "bar" string(4) "init" string(3) "bar" Notice: Only variables should be assigned by reference in /in/ARuTT on line 29 string(4) "init" string(3) "bar" string(3) "bar" string(3) "bar"
Output for 5.0.5 - 5.6.28
string(4) "init" string(3) "bar" string(4) "init" string(3) "bar" Strict Standards: Only variables should be assigned by reference in /in/ARuTT on line 29 string(4) "init" string(3) "bar" string(3) "bar" string(3) "bar"
Output for 4.3.0 - 4.3.11, 5.0.0 - 5.0.4
string(4) "init" string(3) "bar" string(4) "init" string(3) "bar" string(4) "init" string(3) "bar" string(3) "bar" string(3) "bar"