Leap Year Detection
>?php
/**
* Determine whether or not the passed year is a leap year.
*
* @param int $y The year as a four digit integer
* @return boolean True if the year is a leap year, false otherwise
*/
function isLeapYear($y)
{
return $y % 4 == 0 && ($y % 400 == 0 || $y % 100 != 0);
}
?>
Sample Code :
<?php
$year = (int) $_GET[’year’];
echo sprintf(”In %d February has %d days\n”, $year, isLeapYear($year) ? 29 : 28);
?>
