月历,使用了phplib的模板类——template.inc
<?php
include "template.inc";
$str = "<table border>
<colgroup span=5 align=right></colgroup>
<colgroup span=2 align=right style='color:red'></colgroup>
<tr><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th><th>日</th></tr>
<!-- BEGIN Month -->
<tr>
<!-- BEGIN Date -->
<td bgcolor='{color}'>{data}</td>
<!-- END Date -->
</tr>
<!-- END Month -->
</table>
";
$mode = 7;
$n = date("t");
$w = date("w",mktime(0,0,0,date("m"),1,date("Y")));
$w = $w==0?7:$w;
$j = date("j");
$tpl = new template;
$tpl->halt_on_error = "report";
$tpl->set_var("hand",$str);
$tpl->set_block("hand","Month","row");
$tpl->set_block("Month","Date","col");
$d = $i = 1;
while($i <= $n) {
if($d < $w)
$tpl->set_var("data"," ");
else {
$tpl->set_var("color",($i==$j?"#0000FF":""));
$tpl->set_var("data",$i++);
}
$tpl->parse("col","Date",true);
if($d++ % $mode == 0) {
$tpl->parse("row","Month",true);
$tpl->set_var("col");
}
}
if(--$d % $mode > 0) {
while($d++ % $mode) {
$tpl->set_var("data"," ");
$tpl->parse("col","Date",true);
}
$tpl->parse("row","Month",true);
}$tpl->parse("out","hand",true);
$tpl->p(out);
?>
<?php
include "template.inc";
$str = "<table border>
<colgroup span=5 align=right></colgroup>
<colgroup span=2 align=right style='color:red'></colgroup>
<tr><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th><th>日</th></tr>
<!-- BEGIN Month -->
<tr>
<!-- BEGIN Date -->
<td bgcolor='{color}'>{data}</td>
<!-- END Date -->
</tr>
<!-- END Month -->
</table>
";
$mode = 7;
$n = date("t");
$w = date("w",mktime(0,0,0,date("m"),1,date("Y")));
$w = $w==0?7:$w;
$j = date("j");
$tpl = new template;
$tpl->halt_on_error = "report";
$tpl->set_var("hand",$str);
$tpl->set_block("hand","Month","row");
$tpl->set_block("Month","Date","col");
$d = $i = 1;
while($i <= $n) {
if($d < $w)
$tpl->set_var("data"," ");
else {
$tpl->set_var("color",($i==$j?"#0000FF":""));
$tpl->set_var("data",$i++);
}
$tpl->parse("col","Date",true);
if($d++ % $mode == 0) {
$tpl->parse("row","Month",true);
$tpl->set_var("col");
}
}
if(--$d % $mode > 0) {
while($d++ % $mode) {
$tpl->set_var("data"," ");
$tpl->parse("col","Date",true);
}
$tpl->parse("row","Month",true);
}$tpl->parse("out","hand",true);
$tpl->p(out);
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货