/* * PHP日历核心程序编写 * */ $year = isset($_GET['year'])?$_GET['year']:date('Y'); $month = isset($_GET['month'])?$_GET['month']:date('m'); $day = isset($_GET['day'])?$_GET['day']:date('d'); //当年当月的天数 $days = date("t",mktime(0,0,0,$month,1,$year)); //当月的第一天是星期几 $startweek = date("w",mktime(0,0,0,$month,1,$year)); echo '
'; echo ''; echo ' 日'; echo ' | 一'; echo ' | 二'; echo ' | 三'; echo ' | 四'; echo ' | 五'; echo ' | 六'; echo ''; echo ''; for($i=0;$i<$startweek;$i++){ echo " "; } for ($j=1;$j<$days;$j++){ $i++; if($j == $day){ echo " | {$j}"; }else{ echo "{$j}"; } if($i%7 == 0){ echo ''; } } while($i%7!==0){ echo ' '; $i++; } echo ''; echo ''; |