Number is Odd or Even

monif64 · updated August 01, 2020 · PHP
<?php
$number = 12;

if($number % 2 == 0)
{
  echo "$number is divisible by 2 and is an even number";  
}

if($number % 2 != 0)
{
    echo "$number is not divisible by 2 and is an odd number";
}
?>

Comments

Please sign up or log in to contribute to the discussion.