Home >>PHP Programs >PHP Program to check number is even or odd

PHP Program to check number is even or odd

PHP Program to check number is even or odd

In this example, we will create a PHP program to check if a number is odd or even.

The numbers that are divisible by 2, known as Even number and the numbers that are not divisible by 2, known as odd number.

Example 1

<?php  
$number=7362;  
if($number%2==0)  
{  
 echo "$number is Even Number";   
}  
else  
{  
 echo "$number is Odd Number";  
}  
?> 

Output:-
7362 is Even Number
Example 2

<?php 
extract($_REQUEST);
if(isset($check))
{
if($number%2==0)  
{  
 echo "$number is Even Number";   
}  
else  
{  
 echo "$number is Odd Number";  
}  
}
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Form</title>
	</head>
	<body>
		<form method="post">
		<table>
		<tr>
		<td>Enter Your Number</td>
		<td><input type="text" name="number" required/></td>
		</tr>
		<td colspan="2" align="center">
			<input type="submit" value="Even or Odd" name="check"/>
		</tr>
		</form>
	</body>
</html>
</html>

Output:-
Check even or odd

No Sidebar ads