Php - Function to check leap year, How to check leap year ot not

Function to check leap year

How to check leap year ot not

The following php function will check whether the given year is a leap year or not.

<?php

function isLeap($yr) {
echo $yr, ': ', (date('L', strtotime("$yr-01-01")) ? 'is Leap Year' : 'is not leap year'), '';
}

?>

The above function will say the argument passed to the isLeap function as a leap year or not.

Function call & Sample Output:
<?php
isLeap(2000);
isLeap(2001);
isLeap(2002);
isLeap(2003);
isLeap(2004);
?>

Output:
2000: is a Leap Year
2001: is not leap year
2002: is not leap year
2003: is not leap year
2004: is a Leap Year

In the above the function isLeap() is called by passing year as an argument and it will say whether the given argument is a leap year or not.

The topic on Php - Function to check leap year is posted by - Venki

Hope you have enjoyed, Php - Function to check leap yearThanks for your time

Tech Bluff