- 论坛徽章:
- 0
|
这个计算器程序,不知道怎么会有这样一个错误:比如,我登陆时,我是第000000001个用户,但是当我刷新的时候变成了000000003个用户。如果我不要下面生成图片的那段code的话,就不会出现这种问题。这是怎么回事啊???????????
<?php
header("Content-type:image/gif");
$fp=fopen("zzm.txt","r");
$str1=fgets($fp,10) + 0;
$str1++;
fclose($fp);
$fp=fopen("zzm.txt","w");
fputs($fp,$str1);
fclose($fp);
$len1=strlen($str1);
$str2="000000000";
$len2=strlen($str2);
$dir=$len2-$len1;
$rest=substr($str2,0,$dif);
$string=$rest.$str1;
$font=4;
$im=imagecreate(120,31);
$foreground_color=imagecolorallocate($im,255,255,255);
imagefill($im,0,0,$background_color);
$px=(imagesx($im)-8.3*strlen($string))/2;
imagestring($im,3,$px,2,"My Counter",$foreground_color);
imageline($im,1,14,85,14,$foreground_color);
imagestring($im,$font,$px,15.5,$string,$foreground_color);
imagepng($im);
imagedestroy($im);
?> |
|