php中使用GD函数生成计数器
php中使用GD函数生成计数器

Header("Content-type: image/jpeg"); 

$arr = file("counter.txt");
$count = (int)$arr[0];
$fp = fopen("counter.txt","w");
fputs($fp,++$count);
fclose($fp); 

$im = ImageCreate(45,16);
$white = ImageColorAllocate($im,255,255,255);
$black = ImageColorAllocate($im,0,0,0);
imagefill($im,1,1,$black);
ImageString($im,5,0,0,sprintf("%05d",$count),$white);
imageJpeg($im);
imagedestroy($im);
?>