Skip to content

PHP – How To Check Number Is Odd Or Even

Here is simple PHP code snippet to check if a given number is odd or even.

Check Number Is Odd Or Even

function checkEven($val){
     return ($val%2 == 0);
}

How to use checkEven

$val = 7;
if(checkEven($val)){
    echo "Number is even";
} else {
    echo "Number is odd";
}
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments