Check if is even or is odd in PHP

0.33K views
no comments
13 Sep 2014 8:23 pm

FUNCTION TO CHECK IF IS EVEN NUMBER

1
2
3
4
function is_even($number=null){
  return(!($number & 1));
}
<pre>

FUNCTION TO CHECK IF IS ODD NUMBER

1
2
3
function is_odd($number=null){
  return($number & 1);
}

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>