您的位置:首页 > 编程语言 > PHP开发

php万年历原型

2017-11-20 08:23 176 查看
<?php
//计算当月天数
$days=date('t',strtotime('2017-11-1'));

$w=date('w',strtotime('2017-11-1'));

$firstday=1-$w;
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
<center>
<h2>2017年11月</h2>
<table border='1px' width='700px' cellspacing="0">
<tr>
<th>星期日</th>
<th>星期一</th>
<th>星期二</th>
<th>星期三</th>
<th>星期四</th>
<th>星期五</th>
<th>星期六</th>
</tr>

<?php

for($i=$firstday;$i<=$days;){
echo "<tr>";
for($j=1;$j<=7;$j++){
if($i<=0 || $i>$days){
echo "<td></td>";
}else{
echo "<td>{$i}</td>";
}
$i++;
}
echo "</tr>";
}
?>

</table>
</center>
</body>
</tr>
</table>
</center>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: