以前在奧索看看過很多這樣的例子,各各方法複雜,請看如下例子實作圖形計數器。在網頁中使用請用
//存放計數的文字檔案
$count="count. txt";
//計數器的位數,如果不填則預設為6位
$wei="";
//影像的URL路徑
$tu="http:// 127.0.0.1/tcount/images";
?>
if ($wei=="") { $wei=6; }
if (!file_exists($count)) { $fp=fopen($count,"w "); fputs($fp,0,100); fclose($fp); }
if ($REMOTE_ADDR!=$ip) {
$fp=fopen( $count,"r ");
$cc=fgets($fp,100);
$cc=trim($cc);
if ($cc=="") { $cou= 1; }
else { $cou=$cc 1; }
rewind($fp);
fputs($fp,$cou,100);
fclose($fp);
,
setcookie("ip",$REMOTE_ADDR,openDR(p); u=fgets($fp,100);
$cou=trim($cou);
fclose($fp);
$w=strlen($cou);
while($w $cou ="0".$cou;
$w ;
}
$www=strlen($cou); align=center>");n";
while($i $ym=substr($cou,$i,1);
echo "document.write("");n";
$i ;
}
?>
http://www.bkjia.com/PHPjc/315813.html
www.bkjia.com