Home >Backend Development >PHP Tutorial >PHP 简单日历实现代码_PHP

PHP 简单日历实现代码_PHP

WBOY
WBOYOriginal
2016-06-01 12:22:59857browse
复制代码 代码如下:
$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...只能这样了.

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

Statement:
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