Search
 
SCRIPT & CODE EXAMPLE
 

PHP

How to check leap year in php?

$year = 2014;
// Leap years are divisible by 400 or by 4 but not 100
if(($year % 400 == 0) || (($year % 100 == 0) && ($year % 4 == 0))){
    echo "$year is a leap year.";
} else{
    echo "$year is normal year.";
}
Comment

php Program to check if a given year is leap year

<?php
// PHP code to check if a given
// year is leap year
 
function checkYear($year)
{
    // If a year is multiple of 400,
    // then it is a leap year
    if ($year % 400 == 0)
        print("Leap Year");
         
    // Else If a year is multiple of 100,
    // then it is not a leap year
    else if ($year % 100 == 0)
        print("Not a Leap Year");
             
    // Else If a year is multiple of 4,
    // then it is a leap year
    else if ($year % 4 == 0)
        print("Leap Year");
         
    else
        print("Not a Leap Year");
}
 
// Driver code
$year = 2000;
 
checkYear($year);
     
// This code is contributed by ash264
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel default encryption mode 
Php :: call api php 
Php :: wordpress enqueue if shortcode 
Php :: laravel 8 with jetstream 
Php :: valet select php version 
Php :: mysqli real escape string 
Php :: laravel access storage attachment 
Php :: php split array into chunks 
Php :: laravel tinker insert db record 
Php :: laravel packages 
Php :: php curl detect 404 
Php :: enable extensions in php.ini 
Php :: laravel sharing data 
Php :: php json_encode float 
Php :: laravel import csv to database 
Php :: Creating (Declaring) PHP Variables 
Php :: laravel belongs to 
Php :: PHP strip_tags — Strip HTML and PHP tags from a string 
Php :: bootstrap is not defined in laravel 
Php :: set cookie on button click JavaScript 
Php :: laravel eloquent get one column value 
Php :: PHP Ternary Operator With Elseif Example 
Php :: php file_get_contents html with special characters 
Php :: multe data on database laravel 
Php :: PHP - AJAX and PHP 
Php :: how to check if query is successfully inserted laravel 
Php :: laravel creat new model 
Php :: this php 
Php :: php to print array value if key exists 
Php :: connect php in sql server 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =