简体   繁体   中英

Is this an accurate way to count page hits?

<?php
$hitcounter = ('/**************/hits.txt');
$hits = file($hitcounter);
$hits[0] ++;
$fp = fopen($hitcounter , "w");
fputs($fp , "$hits[0]");
fclose($fp);
?>

I added this to the top of a few pages on a website I run yesterday, and today when I checked it, it was at 25,000 and steadily rising. Is this a rational number? Is this a good way to monitor page hits?

Is this a good way to monitor page hits?

I would say no . Database based approach would provide nice & easy features to analyze the hits and do accounting on them (eg store hit time and later on do SELECT ... WHERE DATE(hit_date) = '2015-06-18' . It could be achieved via file based approach but would be an overkill.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM