# Check Even and ODD in PHP

In this PHP program, we are going to check whether a given number is an EVEN number of an ODD number.
Submitted by IncludeHelp, on January 05, 2018

Given a number and we have to check whether it is an EVEN number of an ODD number using PHP Code.

EVEN numbers are the numbers which are divisible by 2, like: 2, 4, 6, 8, 10, etc, and the ODD numbers are not divisible by 2, like: 3, 5,7, 9, 1 etc

Example:

```    Input: 12
Output: 12 is an EVEN number
12 is divisible by 2, it returns remainder 0

Input: 13
Output: 13 is an ODD number
13 is not divisible by 2, because it returns remainder 1
```

## Program to check EVEN and ODD in PHP

```<?php
//program to check EVEN or ODD
//function: isEvenOrOdd
//description: This function will check
//whether a given number is EVEN or ODD
function isEvenOrOdd(\$num){
//if num is divisible by 2 than
//it will be an EVEN number or it
//will be an ODD number
if( \$num % 2 == 0)
return 1; //will check as EVEN number
else
return 0; //will check as ODD number
}

//main code to test the function
\$number = 12;
if(isEvenOrODD(\$number))
print_r(\$number." is EVEN number");
else
print_r(\$number." is ODD number");

print_r("\n");

//again check with an ODD number
\$number = 13;
if(isEvenOrODD(\$number))
print_r(\$number." is EVEN number");
else
print_r(\$number." is ODD number");
?>
```

Output

```12 is EVEN number
13 is ODD number
```

What's New

Top Interview Coding Problems/Challenges!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates