PHP-implemented simple calendar class, php-implemented calendar _ PHP Tutorial

Source: Internet
Author: User
PHP implements a simple calendar class, and php implements a calendar. PHP-implemented simple calendar class. php-implemented calendar this article describes the PHP-implemented simple calendar class. Share it with you for your reference. The specific implementation code is as follows: Copy the code as follows: Simple Calendar class implemented by PHP, calendar implemented by php

This example describes the simple calendar class implemented by PHP. Share it with you for your reference.

The specific implementation code is as follows:

The code is as follows:

Date_default_timezone_set ("etc/GMT-8 ");
Header ("Content-type: text/html; charset = utf-8 ");
Class calendar {
Var $ t = array ();
Var $ datesofmonth = array ('1' => '31', '2' => '28', '3' => '31 ', '4' => '30', '5' => '31', '6' => '30', '7' => '31 ', '8' => '31', '9' => '30', '10' => '31', '11' => '30 ', '12' => '31 ');
Var $ y, $ m, $ d;
Function set ($ time ){
$ This-> t = getdate ($ time );
$ This-> y = $ this-> t ['Year'];
$ This-> m = $ this-> t ['mon'];
$ This-> d = date ('D', $ time );
}
Function isrun (){
Return ($ this-> y % 400 = 0 | ($ this-> y % 4 = 0 & $ this-> y % 100 = 0 ))? 1: 0;
}
Function first (){
$ Time = mktime (0, 0, 0, $ this-> m, 1, $ this-> y );
$ Time = getdate ($ time );
Return $ time ['wday'];
}
Function html (){
$ Isrun = $ this-> isrun ();
$ This-> datesofmonth [2] = $ isrun = 1? 29: 28;
$ Html. ="
























N ";$ Html. =" N ";$ Html. =" Jb51.net N ";$ Html. =" N ";$ First = $ this-> first ();For ($ I = 0; $ I <$ first; $ I ++ ){$ Html. =" ";}$ Count = $ this-> datesofmonth [$ this-> m] + $ first;For ($ I = 1; $ I <= $ this-> datesofmonth [$ this-> m]; $ I ++ ){$ Style = $ I ==$ this-> d? 'Style = "color: red; font-weight: bold ;"':'';$ Html. =" ";If ($ I = 7% $ first | ($ I + $ first) % 7 = 0) & $ I <$ count ){$ Html. =" N ";}}$ Count = 7-$ count % 7;If ($ count <7 ){For ($ I = 0; $ I <$ count; $ I ++ ){$ Html. =" ";}}$ Html. =" N ";$ Html. ="
Last month {$ This-> y} year {$ this-> m} month Next month
Sunday Monday TuesdayWednesday Thursday Friday Saturday
$ I
N ";
Return $ html;
}
}
$ Calendar = new calendar ();
$ Calendar-> set (time ());
Echo $ calendar-> html ();

I hope this article will help you with php programming.

Examples in this article describes the simple calendar class implemented by PHP. Share it with you for your reference. The specific implementation code is as follows: the code is as follows...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.