# PHP Program to Check Whether a Number is Even or Odd using If-else Statement

ADVERTISEMENTS

__PHP__ program to check whether a number is even or odd using if-else statement. In this article, you will learn how to make a PHP program to check whether a number is even or odd using an if-else statement.

## What is even odd numbers?

There is if any integer number divided by 2 and its reminder equals zero then it is an even number and the reminder is greater than zero then it is an odd number.

### Samples of even odd Numbers

**Even Numbers: 0, 2, 4, 6, ...**

`Odd Numbers: 1, 3, 5, 7, ...`

## PHP Program to Check Whether a Number is Even or Odd using If-else Statement

```
<?php
// PHP Program to Check Whether a Number is Even or Odd using If-else Statement
$x = 26;
echo "Input Number: ", $x, "\n\n";
if ($x % 2 == 0) {
echo "The input number is even number.\n";
} else {
echo "The input number is odd number.\n";
}
?>
```

### Output

`Input Number: 26`

`The input number is even number.`

## PHP Program to Check Whether a Number is Even or Odd using Conditional Operator

```
<?php
// PHP Program to Check Whether a Number is Even or Odd using Conditional Operator
$x = 27;
echo "Input Number: ", $x, "\n\n";
$x = $x % 2 == 0 ? 1 : 0;
if ($x) {
echo "The input number is even number.\n";
} else {
echo "The input number is odd number.\n";
}
?>
```

### Output

`Input Number: 27`

`The input number is odd number.`