Check even odd in PHP


Copy Fullscreen Close Fullscreen
<?php
  function check_even_odd($number)
  {
    if($number%2 == 0)
      echo "$number is an even number.";
    else
      echo "$number is an odd number.";
  }

  /*now test*/
  check_even_odd(22);
  echo"<br/>";
  check_even_odd(21);
?>
Output
22 is an even number.
21 is an odd number.

Hey ! I'm Rahul founder of learnhindituts.com. Working in IT industry more than 4.5 years. I love to talk about programming as well as writing technical tutorials and blogs that can help to others .... keep learning :)

Get connected with me - LinkedIn Twitter Instagram Facebook