3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function prim($n) { if ( $n == 1 ) return false; if ( $n == 2 ) return true; if ( $n % 2 == 0 ) return true; for ( $i = 3; $i < $n; $i+=2) { if ( $n % $i == 0 ) return true; } return false; } var_dump(prim(1)); var_dump(prim(2)); var_dump(prim(3)); var_dump(prim(4)); var_dump(prim(5)); var_dump(prim(6)); var_dump(prim(7)); var_dump(prim(8)); var_dump(prim(9)); var_dump(prim(11));
Output for 4.3.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(true) bool(false)