ユニーク ビジター数を表示できるスクリプトを見つけましたが、問題があるようです。停止するまでに 3 回カウントします。私はPHPが得意ではありませんが、問題を理解しようとしましたが、できませんでした。私のコードに何か問題がありますか? これを行うための別のより良い、より簡単な方法はありますか?
<?php
$filename = "UniqueCount.txt";
if (!file_exists($filename))
{
// hits.txt doesn't exist, let's try to create it.
$fd = fopen($filename, "w+");
fclose($fd);
}
$file = file($filename);
$file = array_unique($file);
$hits = count($file);
// Print out the number of unique visitors we have had.
echo $hits;
$fd = fopen($filename, "r");
$fstring = fread($fd, filesize($filename));
fclose($fd);
$fd = fopen($filename, "w");
$fcounted = $fstring . "
" . $_SERVER["REMOTE_ADDR"];
$fout = fwrite($fd, $fcounted);
fclose($fd);
?>
ファイルを作成するときに起動します。私は言って、エラーを取得します
0
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/content/46/10721146/html/UniqueHits.php on line 20
前もって感謝します、
エリートゲーマー