Home  >  Article  >  Backend Development  >  A PHP calendar program_PHP tutorial

A PHP calendar program_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:59:33805browse

//<-------Process variables submitted through the GET method; start-------->
if($HTTP_GET_VARS[year]==" ")
{
$HTTP_GET_VARS[year]=date("Y");
}
if($HTTP_GET_VARS[month]=="")
{
$HTTP_GET_VARS [month]=date("n");
}
$month=$HTTP_GET_VARS[month];
$year=$HTTP_GET_VARS[year];
//<---- ---Process variables submitted through the GET method; end-------->
if($year<1971)
{
echo "Error!";
echo "
";
echo "Back";
exit();
}
?>


< ;tr align="center">

$d=date("d");
$FirstDay =date("w",mktime(0,0,0,$month,1,$year));//Get the day of the week that the first day of any month is, and use it to calculate which cell of the table the first day of the month is Start
$bgtoday=date("d");
function font_color($month,$today,$year)//Used to calculate the font color of Sunday
{
$sunday=date( "w",mktime(0,0,0,$month,$today,$year));
if($sunday=="0")
{
$FontColor="red";
} Else
{
$ fontcolor = "Black";
}
Return $ fontcolor; today_i,$year)//Used to calculate the background color of the day
{
$show_today=date("d",mktime(0,0,0,$month,$today_i,$year));
$sys_today=date("d",mktime(0,0,0,$month,$bgtoday,$year));
if($show_today==$sys_today)
{
$ bgcolor="bgcolor=#6699FF";
}
else
{
$bgcolor="";
function font_style($month,$today,$year)//Font style used to calculate Sunday
{
$sunday=date("w",mktime(0,0,0,$month ,$today,$year));
if($sunday=="0")
{
$FontStyle="";
}
else
{
$Font;
}
return $FontStyle;
}
for($i=0;$i<=$FirstDay;$i++)//This for is used Output the first day position of a certain month
{
for($i;$i<$FirstDay;$i++)
{
echo "
n ";
if($FirstDay==6)//Determine whether the 1st is Saturday
{
echo "
";
} }
}
}
$countMonth=date("t",mktime(0,0,0,$month,1,$year));//Total number of days in a month
for($i=2;$i<=$ countMonth;$i++)//Output starts from the 1st, then all numbers from the 2nd to the end of the month
{
echo "
n";
} }
}



http://www.bkjia.com/PHPjc/317347.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/317347.htmlTechArticle?php //-------Process variables submitted through the GET method; start---- ---- if($HTTP_GET_VARS[year]=="") { $HTTP_GET_VARS[year]=date("Y"); } if($HTTP_GET_VARS[month]=="") { $HTTP_GET_VARS[mon.. .
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

//<------Processing when the month exceeds 1 to 12; Start ------->
if($month<1)
{
$month=12;
$year-=1;
}
if( $month>12)
{
$month=1;
$year+=1;
}
//<------When the month exceeds 1 to 12 Processing; end------->
//******************************** *******
//<---------Connection processing and output of the previous year, next year, last month, and next month; start------- -->
echo "<<>>";
? >

year."><<month> >";
//<--------Connection processing and output of the previous year, next year, last month, and next month; end------ --->
?>
OneTwoThreeFour FiveSix
}
if($i==$FirstDay)
{
echo "
".font_style($month,1,$year)."1
".font_style($month,$i,$year)."$in";
if(date("w",mktime(0,0,0,$month,$i,$year))==6)//Judge whether the day is Saturday
{
echo "