PHP program to check if a given year is Leap year or not

Below is the PHP script to find the given year is leap year or not.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Leap Year</title>
</head>

<body>
    <h2>PHP script to find given year is a leap year or not </h2>
    <form action="" method="POST">
        <input type="number" name="year" />
        <input type="submit" />
    </form>

    <?php
        if ($_POST)
        {
            $year$_POST['year'];
            if(!is_numeric($year))
            {
                echo "String not allowed.
                Input should be a number";
                return ;
            }
            if(($year % 4==0) and ($year % 100!=0) or ($year % 400==0))
            {
                echo "$year is a leap year";
                }
            else
            {
                echo "$year is not a leap year";
            }
        }
        ?>
</body>

</html>

Thank you.

© Copyright - 2018 - 2021 | All rights reserved at Funda of Web IT