一般来说,PHP样式Hit Counter如何在JavaScript中实现?
这个PHP example:
<?php
/* counter */
//opens countlog.txt to read the number of hits
$datei = fopen("/countlog.txt","r");
$count = fgets($datei,1000);
fclose($datei);
$count=$count + 1 ;
echo "$count" ;
echo " hits" ;
echo "\n" ;
// opens countlog.txt to change new hit number
$datei = fopen("/countlog.txt","w");
fwrite($datei, $count);
fclose($datei);
?>
在服务器上运行,而不是像JavaScript一般在浏览器中运行。