Code
1 <?php
2 //imageCounter.php 2009.10.24
3 //定义输出的类型为图形
4 Header("Content-type: image/gif");
5 $fp=fopen("zzm.txt","r");
6 $str1=fgets($fp,10);
7 $str1+=1;
8 fclose($fp);
9 $fp=fopen("zzm.txt","w");
10 fputs($fp,$str1);
11 fclose($fp);
12 $len1=strlen($str1);
13 $str2="000000000";
14 $len2=strlen($str);
15 $dif=$len2-$len1;
16 $rest=substr($str2,0,$dif);
17 $string=$rest.$str1;
18
19 $font=4;
20 //新建图像
21 $im=imagecreate(120,31);
22
23 $background_color=ImageColorAllocate($im,0,0,0);
24 $foreground_color=ImageColorAllocate($im,250,250,250);
25
26 imagefill($im, 0,0, $background_color);
27
28 $px=(imagesx($im)-8.3*strlen($string))/2;
29
30 ImageString($im, 3, $px, 2, "my counter",$foreground_color);
31
32 imageline($im, 1,14,120,14, $foreground_color);
33
34 ImageString($im,$font,$px,15.5,$string,$foreground_color);
35
36 Imagepng($im);
37
38 ImageDestroy($im);
39 ?>
40
1 <?php
2 //imageCounter.php 2009.10.24
3 //定义输出的类型为图形
4 Header("Content-type: image/gif");
5 $fp=fopen("zzm.txt","r");
6 $str1=fgets($fp,10);
7 $str1+=1;
8 fclose($fp);
9 $fp=fopen("zzm.txt","w");
10 fputs($fp,$str1);
11 fclose($fp);
12 $len1=strlen($str1);
13 $str2="000000000";
14 $len2=strlen($str);
15 $dif=$len2-$len1;
16 $rest=substr($str2,0,$dif);
17 $string=$rest.$str1;
18
19 $font=4;
20 //新建图像
21 $im=imagecreate(120,31);
22
23 $background_color=ImageColorAllocate($im,0,0,0);
24 $foreground_color=ImageColorAllocate($im,250,250,250);
25
26 imagefill($im, 0,0, $background_color);
27
28 $px=(imagesx($im)-8.3*strlen($string))/2;
29
30 ImageString($im, 3, $px, 2, "my counter",$foreground_color);
31
32 imageline($im, 1,14,120,14, $foreground_color);
33
34 ImageString($im,$font,$px,15.5,$string,$foreground_color);
35
36 Imagepng($im);
37
38 ImageDestroy($im);
39 ?>
40