php網(wǎng)頁數(shù)字計數(shù)器代碼 本款php計數(shù)器是一款用來統(tǒng)計網(wǎng)頁的訪問次數(shù)的簡單的講數(shù)器代碼,利用txt文本文件與php fopen函數(shù)進行操作。
- $log = 'log/count.txt';
- $count_img = 'img/counter';
- $fp = @fopen($log, "r+") or die($log.'數(shù)據(jù)文件不能打開!');
- $count = fgets($fp, 64);
- flock($fp, 2);
- $count = (int)$count + 1;
- rewind($fp);
- fputs($fp, $count);
- fclose($fp);
- if($conf_showcount == '1'){
- for ($i=0; $i<strlen($count); $i++){
- $num = substr($count, $i, 1);
- echo '<img src="'.$count_img.'/'.$num.'.gif">';
- }
- }
新聞熱點
疑難解答