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. ="
Last month |
{$ This-> y} year {$ this-> m} month |
Next month |
N ";$ Html. ="
Sunday |
Monday |
Tuesday | Jb51.net
Wednesday |
Thursday |
Friday |
Saturday |
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. ="
$ I | ";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. ="
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...