PHP Full Calendar class (Class) _php tutorial

Source: Internet
Author: User
Tags strcmp
Copy CodeThe 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 (
"He", "January",
"The" and "February",
"A" and "March",
"" "and" April ",
"" "and" May ",
"He" and "June",
"" and "July",
"He" and "August",
"He" and "September",
"Ten" = "October",
"One" = "November",
"A" and "December"
);
Set year
function Setyear ($year) {
$this->year= $year;
}
Year of acquisition
function GetYear () {
return $this->year;
}
Set month
function Setmonth ($month) {
$this->month= $month;
}
Get month
function GetMonth () {
return $this->month;
}
Set Date
function Setday ($day) {
$this->day= $day;
}
Date obtained
function GetDay () {
return $this->day;
}
Print a calendar
function out () {
$this->_env ();
$week = $this->getweek ($this->year, $this->month, $this->day);//Get date for day of the week (for example today for 2003-07-18, Friday)
$fweek = $this->getweek ($this->year, $this->month,1); Get the first day of the month for the week
echo "

WEEK) ($Tmpa + +) {//Print week header
echo "

"; for ($Tmpa =0; $Tmpa "; Supplemental print for ($TMPC =0; $Tmpc < $fweek; $TMPC + +) {echo "
". $this->week[$Tmpa];
}
for ($TMPB =1; $TMPB <=date ("T", Mktime (0,0,0, $this->month, $this->day, $this->year)), $TMPB + +) {//Print all dates
if (strcmp ($TMPB, $this->day) ==0) {//Get current date, Mark
$flag = "bgcolor= ' #ff0000 '";
}else{
$flag = ' bgcolor= #ffffff ';
}
if ($TMPB ==1) {
echo "
";
}
}
if (strcmp ($this->getweek ($this->year, $this->month, $TMPB), 0) ==0) {
echo "
$TMPB ";
}else{
echo "
$TMPB ";
}
}
echo "
";
}
Gets the number of weeks of the date specified in the method
function Getweek ($year, $month, $day) {
$week =date ("W", Mktime (0,0,0, $month, $day, $year));//Get Week
return $week;//Get Week
}
function _env () {
if (Isset ($_post["Month")) {//has a specified month
$month =$_post["Month"];
}else{
$month =date ("M"); Default is this month
}
if (Isset ($_post["Year")) {//refers to years
$year =$_post["Year"];
}else{
$year =date ("Y"); Default is this year
}
$this->setyear ($year);
$this->setmonth ($month);
$this->setday (Date ("D"));
}
}
$D =new Calendar;
$D->out ();
?>

http://www.bkjia.com/PHPjc/317183.html www.bkjia.com true http://www.bkjia.com/PHPjc/317183.html techarticle Copy the code as follows: PHP classcalendar{/* *www.jb51.net revision */Var$year, $MONTH, $DAY; Var$week=array ("Sunday", "Monday", "Tuesday", "Wednesday" , "Thursday", "Friday ...

  • 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.