/ 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.
Expand |
Embed | Plain Text
// Change '10' to be any number you want <?=(10&1) ? "odd" : "even"?>
Comments
Subscribe to comments
You need to login to post a comment.

I LOVE THIS CODE OH SO MUCH
Thanks! =)
Cheers! :)
You could technically do the following as well, which is even shorter:
...replacing '10' with your own number. :)
...sorry, that didn't post! :-\
Instead I've added a new shorter version of the script. :)