php实现小小日历
利用PHP中的Image函数实现动态生成GIF图象文件的,用户在不同的时间访问可以返回不同的小日历图片,代码如下:
<?php
 header
("Content-type: image/gif");
 
$y=date(Y);
 
$m=date(n);
 
$w=date(w);
 
$d=date(j);
 
 
$ws[0]="Sun";
 
$ws[1]="Mon";
 
$ws[2]="Tue";
 
$ws[3]="Wed";
 
$ws[4]="Thu";
 
$ws[5]="Fri";
 
$ws[6]="Sat";
 
$image imagecreate(80,100);
 
 if (
$w==||$w==6) {
     
$colorWimagecolorallocate($image22500);
  }
 else{
     
$colorWimagecolorallocate($image00255);
  }  
 
 
 
$colorbk imagecolorallocate($image0,0,120);
 
$colorGreen imagecolorallocate($image02250);
 
$colorB imagecolorallocate($image255,255,255);
 
$colorBlackimagecolorallocate($image0,0,0);
 
 
imagefill($image00$colorbk);
 
 
imagefilledrectangle($image10,10,70,90$colorB);
 
 
imagestring($image52315,$y$colorBlack);    
 
imagestring($image53635,$m$colorGreen);
 
imagestring($image53255,$d$colorW);    
 
imagestring($image43075,$ws[$w], $colorW);  
 
imagegif($image);
 
 
?>
 说明:您的PHP必须有支持GIF图象的GD Library,如果您现在的PHP不支持,请去下载以前GD Library