Home > php教程 > php手册 > body text

PHP 简单日历实现代码

WBOY
Release: 2016-06-13 12:21:11
Original
977 people have browsed it

复制代码 代码如下:


$monthoneday=date("Ym")."01";
$oneweekday=date("w",strtotime($monthoneday)); //获得本月1号星期几
$monthday=date("t"); //本月多少天
$startlow=($oneweekday==0)?7:$oneweekday; //从第几列开始

for($a=1,$b=$startlow;$a$ary[$b]=$a; //用数组控制日期在哪里输出
}
$c=1;
//输出行数等于当月天数除7取整再加1
for($a=1;$aecho "

";
//我是用数组的key来控制在哪能里输出的
for($b=1;$bif($ary[$c]==date("j")){
echo '';
}else{
echo " ";
}
echo $ary[$c];
echo "";
echo "\n";
}
echo "";
}
?>

写法估计和别人写得不一样...呵...就这点程序我写了半天,刚开始一直是循环思路有问题.居然输出31行1234呵...
看来只有多写才能锻练思维...这个应该用JS实现的,可是我不会JS...只能这样了.

下面是效果...主要是模板挺好看的...

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!