How to check if a number is odd or even


/ Published in: PHP

How to check if a number is odd or even in PHP. Could also use the MOD (%) function, but apparently this method is better performance-wise.


Copy this code and paste it in your HTML
  1. // Change '10' to be any number you want
  2. <?=(10&1) ? "odd" : "even"?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.