WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Find if a year is leap.
Categories : PHP, Date Time, Beginner Guides, Data Validation Click here to Update Your Picture
Aris Karidis
Date : Jan 19th 2006
Grade : 5 of 5 (graded 1 times)
Viewed : 10667
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Aris Karidis
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
/**
* This function gets a year as a parameter and returns an integer,
* which is 29 for leap years and 28 for normal years.
*
* @param int $year
* @return int
*/
function isLeapYear($year)
{
   
# Check for valid parameters #
   
if (!is_int($year) || $year < 0)
    {
       
printf('Wrong parameter for $year in function isLeapYear. It must be a positive integer.');
        exit();
    }
       
   
# In the Gregorian calendar there is a leap year every year divisible by four
    # except for years which are both divisible by 100 and not divisible by 400.
       
   
if ($year % 4 != 0)
    {
        return
28;
    }
    else
    {
        if (
$year % 100 != 0)
        {
            return
29;    # Leap year
       
}
        else
        {
            if (
$year % 400 != 0)
            {
                return
28;
            }
            else
            {
                return
29;    # Leap year
           
}
        }
    }
}
?>



Find the number of days between today and a date in the future or in the past.
Categories : PHP, Date Time, Beginner Guides, Data Validation
Find the day of the week for any given year/month/day.
Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Validating a URL with preg_match
Categories : PHP, Regexps, Beginner Guides, Data Validation
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
Form Validation Using PHP to highlight non valid fields
Categories : PHP, Form Processing, Data Validation, Beginner Guides
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
Local Time clock and Server time usign PHP and JavaScript
Categories : PHP, Java Script, Date Time, Beginner Guides
Change the background color of a website daily dynamically using the php date function to get the current day of the week and depending on that day, set the background color for the web page.
Categories : PHP, Date Time, Beginner Guides, Web Design
How to Insert a Date Format Into MySQL from PHP
Categories : PHP, Databases, MySQL, Date Time, Beginner Guides
Script loading time
Categories : PHP, Beginner Guides, Date Time
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
A Timing Class
Categories : PHP, PHP Classes, Date Time
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides