PHP program to check prime number:
The below program checks if a number is a prime or a composite number. The PHP echo statement is used to output the result on the screen.
Example
<!DOCTYPE html> <html> <body> <?php $num = 13; $count=0; for ( $i=1; $i<=$num; $i++) { if (($num%$i)==0) { $count++; } } if ($count<3) { echo "$num is a prime number."; } else { echo "$num is not a prime number."; } ?> </body> </html> |
Output
13 is a prime number. |