3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [1, 2, 3, 4]; foreach (1 ? $a : [] as &$x) { $x += 10; } print_r($a); $a = [1, 2, 3, 4]; $a = $b; foreach (1 ? $a : [] as &$x) { $x += 10; } print_r($a);
Output for 7.0.0 - 7.2.0
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) Notice: Undefined variable: b in /in/LIJna on line 10 Warning: Invalid argument supplied for foreach() in /in/LIJna on line 11
Output for 5.5.24 - 5.6.28
Array ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 ) Notice: Undefined variable: b in /in/LIJna on line 10 Warning: Invalid argument supplied for foreach() in /in/LIJna on line 11
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '&' in /in/LIJna on line 4
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/LIJna on line 3
Process exited with code 255.