使用PHP制作一个万年历

主要运用date函数和mktime函数

完成结果如下:

使用PHP制作一个万年历_第1张图片

代码如下:

";
	$c .= "

{$year}年{$mon}月

"; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $c .= ""; $dd = 1; while ($dd <= $day) { $c .= ""; for ($i=0; $i < 7; $i++) { if (($dd>$day) || ($dd==1 && $w>$i)) { $c .= ""; }else{ $c .= ""; $dd++; } } $c .= ""; } $c .= "
星期日星期一星期二星期三星期四星期五星期六
{$dd}
"; echo $c; $yearList = ''; for ($i=1990; $i < 2050; $i++) { $select = ''; if($year==$i){ $select = 'selected="selected"'; } $yearList .= ''; } $monList = ''; for ($i=1; $i < 12; $i++) { $select = ''; if($mon==$i){ $select = 'selected="selected"'; } $monList .= ''; } ?> 万年历


你可能感兴趣的:(PHP)