php-tutorialmade

PHP Program to find leap year

This PHP program will print the output whether the entered year is a leap year or not.

Three steps are there to find a leap year:

1. year % 4 == 0 -> evenly divisible by 4
2. and year % 100 != 0 -> should not be evenly divisible by 100
3. or year % 400 == 0 -> evenly divisible by 400

if 1st  and 2nd is true  or 3rd is true then it is a leap year.

Here is the entire PHP program to find leap year:

Read the comments in the program to understand the flow.

Here is the demo of this program:

demo

 

 

Related Posts

One thought on “PHP Program to find leap year

  1. hi can u explain this code
    1. year % 4 == 0 -> evenly divisible by 4
    2. and year % 100 != 0 -> should not be evenly divisible by 100
    3. or year % 400 == 0 -> evenly divisible by 400

    i did not get

Leave a Reply