3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php for($i=0; $i<3; $i++) { echo $i; // 1, 2, 3 foreach($something as $value) { echo $i; // 0 foreach($value as $moreSomething) { echo $i; // 0 $object->addStuff($i, $moreSomething); // i = 0, moreSomething is correct } } }
Output for 5.1.0 - 7.1.0
0 Notice: Undefined variable: something in /in/aKikA on line 5 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5 1 Notice: Undefined variable: something in /in/aKikA on line 5 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5 2 Notice: Undefined variable: something in /in/aKikA on line 5 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.5
0 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5 1 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5 2 Warning: Invalid argument supplied for foreach() in /in/aKikA on line 5
Output for 4.3.11
012