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"; }