Complete Code For Checking Given Year Is Leap Year Or Not Using PHP.
<!DOCTYPE html>
<html>
<head>
<title>How To Check Given Year Is Leap Year Or Not Using PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
body {
background: black;
}
</style>
<body>
<body>
<div class="container">
<br/><br/>
<div class="text-center">
<h1 id="color" style="color: white;">Check Given Year Is Leap Year Or Not Using PHP</h1>
</div>
<div class="well">
<form action="" method="post" >
<label>Enter year</label><br>
<input type="number" name="year" value=""><br><br>
<input type="submit" value="submit" class="btn btn-success" name="submit">
</form>
<?php
if(isset($_POST['submit']))
{
//get the year
$year = $_POST['year'];
//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";
}
}
?>
</div>
</div>
</body>
</html>