Showing posts with label leap year program using php. Show all posts
Showing posts with label leap year program using php. Show all posts

Saturday, May 25, 2024

PHP using leap year program

 PHP Using leap year program 

PHP using leap year program


                       Leap Year 

1]  leap year is the one  has 366 days in a year.

2] leap year comes after every four years.

3]  leap year is always a multiple of four.

4] For example,1999,2000, 2007,2008,2009,2010, 2020, 2024, etc are leap years.


Q. Leap Year Program php

 Example

<?php
function isLeap($year)
{
    return(date('L',mktime(0,0,1,1, $year))==1);
}
    for($year=1991; $year<2016;$year++)
    {
        if(isLeap($year))
        {
            echo "$year : LEAP YEAR <br>\n";
        }
        else
        {
            echo "$year:Not leap year<br>\n";

        }
    }
?>

Q. leap year program php

    Output :

leap year program php


 Q. leap year program using  form php

    Example


<html>
    <form method="post">
        Enter the Year : <input type ="text"
name="year">
        <input type="submit" name="submit"
value="submit">
</form>
<?php
if($_POST)
{
    $year = $_POST['year'];
    if(!is_numeric($year))
    {
        echo "string not allowed,
Input should be a number";
        return;
    }
    if((0==$year %4 )and(0!=$year % 100)or
(0==$year%400))
    {
        echo "$year this number is a Leap Year";
    }
    else{
        echo "$year  this numberis not
a Leap Year";

    }
}
?>


Q. leap year program using  form php

    Output :



leap year program php

PHP using leap year program


READ MORE :-

sum of digits