Leap Year Determination : Logical Operators « Operator « PHP






Leap Year Determination

 
<?php
function is_leap_year($year) {
    return ((($y % 4) == 0) && ((($y % 100) != 0) || (($y % 400) == 0)));
}

foreach (range(1999, 2009) as $year) {
    echo "<p>{$year} = ", is_leap_year($year) ? 'Leap Year' : 'not', '</p>';
}
?>
  
  








Related examples in the same category

1.Logical Operators in Order of Precedence
2.Use the boolean compare operators
3.Greater than
4.Less than
5.Greate and equal
6.Less than and equal
7.Not equal: !=
8.Logical Operators
9.Logic Operators in PHP
10.Or operator
11.Negation operator
12.The not-equals operator
13.Relational Operators summary table
14.Relational Operators in action