In this program, you will check whether the given year is a leap year or not using if-else condition
<?php
$year=2020;
if(($year%4)==0)
{
if(($year%100)==0)
{
if(($year%400)==0)
{
echo "$year is a leap year";
}
else{
echo "$year is not a leap year";
}
}
else{
echo "$year is a leap year";
}
}
else{
echo "$year is not a leap year";
}
?>
2020 is a leap year
In this program, you will take year input from user in HTML form and you will find whether year enter by user is leap year or not.
<!DOCTYPE html>
<html lang="en">
<head>
<title>check year is leap year or not</title>
</head>
<body>
<form>
<label> Enter the Year </label> <input type="number" name="LeapYear">
<input type="submit" value="submit" name="submitForm"></br></br>
</form>
</body>
</html>
<?php
if(isset($_GET["submitForm"]))
{
$year=$_GET['LeapYear'];
if(($year%4)==0)
{
if(($year%100)==0)
{
if(($year%400)==0)
{
echo "$year is a leap year";
}
else{
echo "$year is not a leap year";
}
}
else{
echo "$year is a leap year";
}
}
else{
echo "$year is not a leap year";
}
}
?>