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.

code:-

<?php

$value=7;
for($i=1;$i<=$value;$i++)
{
    if($value%$i==0)
    {
        echo "prime number";
        break;
    }
    else{
        echo "not prime";
        break;
    }
}
?>


output:
prime number

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post