Prime numbers in PHP

Write PHP program to take numbers from the user and print all prime numbers between the given range.

prime number between 1 to 100 in php

<?php
echo'prime number between 1 to 100 are:</br>';
for($i=1;$i<=100;$i++)
    {      
        $b=0;
        for($j=1;$j<=$i;$j++)
        {
            if($i%$j==0)
            {
                $b=$b+1;
            }
        }
        if($b==2)
        {
            echo ' '.$i;
        }
    }
?>

output

prime number between 1 to 100 are:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Program to print all prime number between 1 to given range by using HTML form

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Print all prime number from 1 to given range</title>
</head>
<body>
    <form>
       <label> Enter the number </label> <input type="number" name="PrimeNumber">
    <input type="submit" value="submit" name="submitForm"></br></br>
    </form>
</body>
</html>
<?php
if(isset($_GET["submitForm"]))
{
    $num=$_GET['PrimeNumber'];
    echo'prime number between 1 to '.$num.' are:</br>';
    for($i=1; $i<=$num; $i++)
    {      
        $b=0;
        for($j=1;$j<=$i;$j++)
        {
            if($i%$j==0)
            {
                $b=$b+1;
            }
        }
        if($b==2)
        {
            echo ' '.$i;
        }
    }
}
?>

output

PHP program to print all prime number in a given range