"Find odd even number " is the basic PHP program for a PHP learner. As you all aware, Odd numbers are not divisible by 2 and Even numbers are divisible by 2.
Example :
Odd number: 3, 5, 7, 9,11
Even number: 2, 4, 6, 8, 10
So here I am gonna explain it with a simple PHP program.
Odd Even Number Program :-
<?php $number=22; if($number%2==0) { echo "22 is an even number"; } else { echo "22 is not odd number"; } ?>
Output :-
22 is an even number
You can also do this by defining a PHP function to check a number is odd or even as below -
PHP function to check odd even number :-
<?php function checkOddEven($num) { if($num%2==0) { $result = "Even number"; } else { $result = "Odd number"; } retrun $result; } echo checkOddEven(43); ?>
Output :-
Odd number
Note: Only a member of this blog may post a comment.