3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function is_prime($num) { $n = $num - 1; while ($n > 1) { if (is_int($num / $n)) { return false; } $n--; } return true; } header('Content-type: text/plain'); foreach (range(1,10) as $num) { if (is_prime($num)) { echo "$num is prime\n"; } else { echo "$num is not prime\n"; } }
Output for 4.3.0 - 7.1.7
1 is prime 2 is prime 3 is prime 4 is not prime 5 is prime 6 is not prime 7 is prime 8 is not prime 9 is not prime 10 is not prime