PHP 7 Script to Check Whether the Number is Prime or Not in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be checking whether the number is prime or not in browser using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

<html>
<body>
<form method='post'>
enter a number<input type="text" name="a">
<input type="submit" name="submit">
</form>
</body>
</html>

<?php
$b=$_POST["a"];
$c=0;
if(isset($_POST["submit"]))
{
if($b==0)
{
  echo "enter number other than 0";
  exit();
}
for($i=2;$i<$b;$i++)
{
  if($b%$i==0)
  $c++;

}
if($c==0)
  echo "$b is a prime number";
else
  echo "$b not a prime number";

}?>

Leave a Reply