Check if a Number is Even or Odd with PHP
by Bandicoot Marketing on | Posted in Tutorials | 12 comments
Ever needed to check if a number is even or odd? If so, here is a pretty simple piece of code that does just that.
<?php $num = 13; if($num&1) { echo 'The number is odd.'; } else { echo 'The number is even.'; } ?>
12 comments for “Check if a Number is Even or Odd with PHP”