5 ways to check if an integer is even or odd. PHP does not provide any mathematical function like is_even to help you check if a given integer is an Even number or Odd. Writing your own such function is not difficult and below are listed a number of alternatives that provide different logical solutions to do this.

    function is_even( $int ) {
        return !( ( ( int ) $int ) & 1 );
Source: http://pageconfig.com/post/finding-even-or-odd-numbers-with-php

Leave a Comment

You must be logged in to post a Review.