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; foreach ( $i = 3; $i <= ceil(sqrt($n)); $i = $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 5.3.0 - 5.4.15
Parse error: syntax error, unexpected ';' in /in/IvIB3 on line 10
Process exited with code 255.