General

PHP Even Function

Dec 16, 2007 insic 1 Comment

Sample PHP Code that checks number if its Even.

Output is

function isEven($number){
$result = $number % 2;
if($result == 0){
return true;
}else{
return false;
}
}

$number = 24;

if(isEven($number)){
echo '

‘;
echo ‘The number is Even’;
echo ‘

‘;
}
?>

About the author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.

  • http://none Ace Macaro

    function isEven($number) {
    return ($number % 2 == 0) ? true : false;
    }

    Usage:
    ——
    $number = 24;
    if (isEven($number)) {
    echo “The number is even”;
    }

    Usage 2:
    ——–
    $number = 24;
    echo (isEven($number)) ? “The number is even” : “The number is NOT even”;