简单的万年历函数
<? 
  
//前几天需要个万年历函数,在oso上看了个万年历,程序功能到是强大,只不过太繁琐。
  //不合自己的要求,因此就自己写了一个,还可以给日期加上连接!
  
function calendar($year,$moon){
    
$moon1=array("01","02","03","04","05","06","07","08","09","10","11","12");
    
$moon2=array("31","28","31","30","31","30","31","31","30","31","30","31");
    if((
$year-2000)%4==0){$moon2[1]=29;}
    for(
$i=0;$i<=11;$i++){
      if(
$moon1[$i]==$moon){
        
$total=$moon2[$i];
      }
    }
    
$out_chat="<table width='90%' cellspacing='0' cellpadding='0' bordercolorlight='#000000' bordercolordark='#FFFFFF' border='1' align='center'>";
    
$out_chat.="<tr><td width=10>日</td><td width=10>一</td><td width=10>二</td><td width=10>三</td><td width=10>四</td><td width=10>五</td><td width=10>六</td></tr>";
    for(
$i=1;$i<=$total;$i++){
      
$j=$i;
      if(
$i<10){
        
$j="0".$i;
      }
      
$time_array=getdate(mktime(0,0,0,$moon,$j,$year));
      if(
$i==1){
        switch(
$time_array[wday]){
          case 
"0":
            
$out_chat.="<tr><td width=10>".$i."</td>";
          break;
          case 
"1":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>".$i."</td>";
          break;
          case 
"2":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>".$i."</td>";
          break;          
          case 
"3":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>".$i."</td>";
          break;            
          case 
"4":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>".$i."</td>";
          break;
          case 
"5":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>".$i."</td>";
          break;
          case 
"6":
            
$out_chat.="<tr><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>".$i."</td>"
          break;
        }
      }else{
        if(
$i!=$total){
          if(
$time_array[wday]!=0){
            
$out_chat.="<td width=10>".$i."</td>";
          }else{
            
$out_chat.="</tr><tr><td width=10>".$i."</td>";
          } 
        }elseif(
$i==$total){
          switch(
$time_array[wday]){
            case 
"0":
              
$out_chat.="</tr><tr><td width=10>".$i."</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td></tr>";
            break;
            case 
"1":
              
$out_chat.="<td width=10>".$i."</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td></tr>";
            break;
            case 
"2":
              
$out_chat.="<td width=10>".$i."</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td></tr>";
            break;
            case 
"3":
              
$out_chat.="<td width=10>".$i."</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td></tr>";
            break;
            case 
"4":
              
$out_chat.="<td width=10>".$i."</td><td width=10>&nbsp;</td><td width=10>&nbsp;</td></tr>";
            break;
            case 
"5":
              
$out_chat.="<td width=10>".$i."</td><td width=10>&nbsp;</td></tr>";
            break; 
            case 
"6":
              
$out_chat.="<td width=10>".$i."</td></tr>"
            break;
          }
        }
      }
    }
    
$out_chat.="</table>";
    return 
$out_chat;
  }

  
$year='2000';
  
$moon='08';
  
$test=calendar($year,$moon);
  echo 
$test;
?>