PHP complete calendar CLASS ). Copy the code as follows :? PhpclassCalendar {** www.jb51.net revised version * var $ YEAR, $ MONTH, $ DAY; var $ WEEKarray (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday
The code is as follows:
Class Calendar {
/*
* Www.jb51.net revised version
*/
Var $ YEAR, $ MONTH, $ DAY;
Var $ WEEK = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
Var $ _ MONTH = array (
"01" => "August January ",
"02" => "August February ",
"03" => "August March ",
"04" => "August April ",
"05" => "August May ",
"06" => "August June ",
"07" => "August July ",
"08" => "August ",
"09" => "August September ",
"10" => "August October ",
"11" => "August November ",
"12" => "August December"
);
// Set the year
Function setYear ($ year ){
$ This-> YEAR = $ year;
}
// Obtain the year
Function getYear (){
Return $ this-> YEAR;
}
// Set the month
Function setMonth ($ month ){
$ This-> MONTH = $ month;
}
// Obtain the month
Function getMonth (){
Return $ this-> MONTH;
}
// Set the date
Function setDay ($ day ){
$ This-> DAY = $ day;
}
// Obtain the date
Function getDay (){
Return $ this-> DAY;
}
// Print the calendar
Function OUT (){
$ This-> _ env ();
$ Week = $ this-> getWeek ($ this-> YEAR, $ this-> MONTH, $ this-> DAY ); // Obtain the day of the week (for example, today is, Friday)
$ Fweek = $ this-> getWeek ($ this-> YEAR, $ this-> MONTH, 1); // Obtain the day of the week on the first day of the MONTH.
Echo"
WEEK); $ Tmpa ++) {// Print the weekly header
Echo"
";For ($ Tmpa = 0; $ Tmpa
". $ This-> WEEK [$ Tmpa];
}
For ($ Tmpb = 1; $ Tmpb <= date ("t", mktime (0, 0, $ this-> MONTH, $ this-> DAY, $ this-> YEAR); $ Tmpb ++) {// print all dates
If (strcmp ($ Tmpb, $ this-> DAY) = 0) {// Obtain the current date and mark it
$ Flag = "bgcolor = '# ff0000 '";
} Else {
$ Flag = 'bgcolor = # ffff ';
}
If ($ Tmpb = 1 ){
Echo" |
"; // Supplemental printingFor ($ tnmpc = 0; $ tnmpc <$ fweek; $ Tmpc ++ ){Echo"
";
}
}
If (strcmp ($ this-> getWeek ($ this-> YEAR, $ this-> MONTH, $ Tmpb), 0) = 0 ){
Echo" |
$ Tmpb ";
} Else {
Echo" |
$ Tmpb ";
}
}
Echo" |
";
}
// Obtain the number of weeks of the specified date in the method.
Function getWeek ($ year, $ month, $ day ){
$ Week = date ("w", mktime (0, 0, 0, $ month, $ day, $ year); // Obtain the week
Return $ week; // Obtain the week
}
Function _ env (){
If (isset ($ _ POST ["month"]) {// Has a specified month
$ Month = $ _ POST ["month"];
} Else {
$ Month = date ("m"); // The default value is this month.
}
If (isset ($ _ POST ["year"]) {// year
$ Year = $ _ POST ["year"];
} Else {
$ Year = date ("Y"); // The default value is this year.
}
$ This-> setYear ($ year );
$ This-> setMonth ($ month );
$ This-> setDay (date ("d "));
}
}
$ D = new Calendar;
$ D-> OUT ();
?>
The http://www.bkjia.com/PHPjc/317183.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/317183.htmlTechArticle code is as follows :? Php classCalendar {/** www.jb51.net revised version */var $ YEAR, $ MONTH, $ DAY; var $ WEEK = array ("Sunday", "Monday", "Tuesday ", "Wednesday", "Thursday", "Friday...