This program states whether a year is leap year or not by inserting a year in the form.
Example:
<html>
<body>
<form method="post">
Enter the Year: <input type="text" name="year">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
<?php
if($_POST)
{
//get the year
$year = $_POST['year'];
//check if entered value is a number
if(!is_numeric($year))
{
echo "Strings not allowed, Input should be a number";
return;
}
//multiple conditions to check the leap year
if( (0 == $year % 4) and (0 != $year % 100) or (0 == $year % 400) )
{
echo "$year is a Leap Year";
}
else
{
echo "$year is not a Leap Year";
}
}
?>
Output:
On entering year 2016, we get the following output.
On entering year 2019, we get the following output.
Leap Year Program
This program states whether a year is leap year or not from the specified range of years (1991 - 2016).
Example:
Output:
Leap Year Program in Form
This program states whether a year is leap year or not by inserting a year in the form.
Example:
Output:
On entering year 2016, we get the following output.
On entering year 2019, we get the following output.

need an explanation for this answer? contact us directly to get an explanation for this answer