- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP program to check if a year is leap year or not
To check if a year is leap year or not in PHP, the code is as follows −
Example
<?php function year_check($my_year){ if ($my_year % 400 == 0) print("It is a leap year"); else if ($my_year % 100 == 0) print("It is not a leap year"); else if ($my_year % 4 == 0) print("It is a leap year"); else print("It is not a leap year"); } $my_year = 1900; year_check($my_year); ?>
Output
It is not a leap year
A function named ‘year_check’ is defined that takes a year as a parameter. It checks to see if the year can be divided by 400 or 4 completely, if yes, it means it is a leap year. Otherwise, it is a leap year. The value for year is defined outside the function, and the function is called by passing this year as a parameter to it. Relevant output is displayed on the console.
- Related Articles
- JavaScript program to check if a given year is leap year
- Program to check if a given year is leap year in C
- Golang Program to Check Whether a Given Year is a Leap Year
- How to check whether a year or a vector of years is leap year or not in R?
- Check if a given year is leap year in PL/SQL
- C++ Program to Check Leap Year
- Java Program to Check Leap Year
- How to find leap year or not in android using year API class?
- How to detect if a given year is a Leap year in Oracle?
- How to Check Leap Year using Python?
- Java program to find if the given number is a leap year?
- Python Pandas - Check whether the year is a leap year from the Period object
- Python Pandas - Indicate whether the date in DateTimeIndex belongs to a leap year or not
- PHP program to check if a number is prime or not
- How to find a leap year using C language?

Advertisements