PHP - 访客计数器
php 代码
<?php
$counterFile = "counter.txt";
function displayCounter($counterFile) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,4096);
$num += 1;
print "您是第 " . $num . " 位小朋友";
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
}
if (!file_exists($counterFile)) {
exec( "echo 0 > $counterFile");
}
displayCounter($counterFile);
?>