3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getNumber() { echo "hi"; return array(1, 2, 3); } foreach(count(getNumber()) as $num) { echo $num; } echo "<br /><br />"; $count = count(getNumber()); for($i=0; $i<count(getNumber()); $i++) { echo $i; }
based on QXQEe
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.6.28, 7.0.0 - 7.1.0
hi Warning: Invalid argument supplied for foreach() in /in/q4mQO on line 9 <br /><br />hihi0hi1hi2hi
Output for hhvm-3.10.0 - 3.12.0
hi Warning: Invalid argument supplied for foreach() in /in/q4mQO on line 11 <br /><br />hihi0hi1hi2hi
Output for 4.3.11
hi<br /><br />hihi0hi1hi2hi