CodesJava

Easy learning with example program codes

PHP program to check leap year

PHP program to check leap year:

The below program is to check if the given year is a leap year or not. The PHP echo statement is used to output the result on the screen. A normal year is of 365 days. A year with 366 days is called a leap year. After every four years, there is a leap year.

Leap Year Conditions:

Remainder (Year/ 4) = 0     =>    Remainder (Year/ 100) != 0   “OR”   Remainder (Year/ 400) = 0.

Example: 2020, 2024, 2028, etc.

Example

<!DOCTYPE html>
<html>
<body>
 
<?php  
$year = 2032;  
 
if((0 == $year % 4) & (0 != $year % 100) | (0 == $year % 400))
{
echo "$year is a Leap Year.";    
}
 
else  
{  
echo "$year is not a Leap Year.";    
}
?> 
 
</body>
</html>

Output

2032 is a Leap Year.
Please follow and like us:
error
Posted in PHP   








Copyright © 2019 CodesJava DMCA.com Protection Status