/*
* 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');
//當(dāng)年當(dāng)月的天數(shù)
$days = date("t",mktime(0,0,0,$month,1,$year));
//當(dāng)月的第一天是星期幾
$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 '
';
網(wǎng)頁題目:PHP簡單日歷編寫
文章起源:
http://weahome.cn/article/jsdeoo.html