Complete Code For Getting Leap Years From Specified Range Of Years In PHP.
<!DOCTYPE html> <html> <head> <title>How To Get Leap Years From Specified Range Of Years In 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;">How To Get Leap Years From Specified Range Of Years In PHP</h1> </div> <div class="well"> <form action="" method="post" > <label>Enter From year</label><br> <input type="number" name="from_year" value=""><br><br> <label>Enter To year</label><br> <input type="number" name="to_year" value=""><br><br> <input type="submit" value="submit" class="btn btn-success" name="submit"> </form> <?php if(isset($_POST['submit'])) { //get the year $from_year = $_POST['from_year']; $to_year = $_POST['to_year']; function isLeap($year) { return (date('L', mktime(0, 0, 0, 1, 1, $year)) == 1); } //For testing for ($year = $from_year ; $year < $to_year; $year++) { if (isLeap($year)) { echo "$year : LEAP YEAR<br />\n"; } else { echo "$year : Not leap year<br />\n"; } } } ?> </div> </div> </body> </html>