/* * 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 ‘<table border="0" width="300" align="center">‘; echo ‘<tr>‘; echo ‘<th bgcolor="pink">日</th>‘; echo ‘<th bgcolor="pink">一</th>‘; echo ‘<th bgcolor="pink">二</th>‘; echo ‘<th bgcolor="pink">三</th>‘; echo ‘<th bgcolor="pink">四</th>‘; echo ‘<th bgcolor="pink">五</th>‘; echo ‘<th bgcolor="pink">六</th>‘; echo ‘</tr>‘; echo ‘<tr>‘; for($i=0;$i<$startweek;$i++){ echo "<td> </tc>"; } for ($j=1;$j<$days;$j++){ $i++; if($j == $day){ echo "<td bgcolor=‘pink‘>{$j}</td>"; }else{ echo "<td>{$j}</td>"; } if($i%7 == 0){ echo ‘</tr><tr>‘; } } while($i%7!==0){ echo ‘<td> </td>‘; $i++; } echo ‘</tr>‘; echo ‘</table>‘;
本文出自 “津沙港湾” 博客,请务必保留此出处http://11410485.blog.51cto.com/11400485/1841009
原文地址:http://11410485.blog.51cto.com/11400485/1841009