3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = "hello"; $b = "hi"; $val = "howdy"; $val = "a"; echo $$val; // outputs "hello" $val = "b"; echo $$val; // outputs "hi" echo $val; // outputs "howdy" echo $"val"; // also outputs "howdy"
Output for 5.4.0 - 5.4.14
Parse error: syntax error, unexpected '"val"' (T_CONSTANT_ENCAPSED_STRING), expecting variable (T_VARIABLE) or '$' in /in/FtBHq on line 14
Process exited with code 255.
Output for 5.3.0 - 5.3.24
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in /in/FtBHq on line 14
Process exited with code 255.

preferences:
177.27 ms | 1395 KiB | 47 Q