php自动生成月历代码
/* function written by nelson neoh @3/2004. for those who wants to utilize this code, please do not remove this remark. if you have done any enhancement to this code, please post the copy at http://www.dev-club.com php board. thank you. function usage: calendar(month,year) */ function calendar($mm,$yyyy){ if($mm==) $mm = date(m); if($yyyy==) $yyyy = date(y); if(checkdate($mm,1,$yyyy)){ $stringdate = strftime(%d %b %y,mktime (0,0,0,$mm,1,$yyyy)); $days = strftime(%d,mktime (0,0,0,$mm+1,0,$yyyy)); $firstday = strftime(%w,mktime (0,0,0,$mm,1,$yyyy)); $lastday = strftime(%w,mktime (0,0,0,$mm,$days,$yyyy)); $printdays = $days; $premonth = strftime(%m,mktime (0,0,0,$mm-1,1,$yyyy)); $preyear = strftime(%y,mktime (0,0,0,$mm-1,1,$yyyy)); $nextmonth = strftime(%m,mktime (0,0,0,$mm+1,1,$yyyy)); $nextyear = strftime(%y,mktime (0,0,0,$mm+1,1,$yyyy)); print(); print(p); print(.strftime(%b %y,mktime (0,0,0,$mm,1,$yyyy)).); print(n
); print(); print(sunmontuewedthufrisat
); $currentdays = 1; for($a=1;$a$lastday && $currentdays ==1 && ($diffdays1)){ for($x=$lastday;$x>=0;$x--){ $printdays = $days-$x; print($printdays ); } for($z=1;$z<$firstday-$lastday;$z++){ print( ); } for($y=$firstday;$y<7;$y++){ print($currentdays ); $currentdays++; } } elseif($firstday!=0 && $currentdays==1){ for($z=1;$z<=$firstday;$z++){ print( ); } for($y=$firstday;$y<7;$y++){ print($currentdays ); $currentdays++; } } else { for($u=1;$u<=7 && $currentdays<=$days;$u++){ print($currentdays ); $currentdays++; } } print(
); } print(
); } }