这里主要用到了session保存当前访问者,并将访问次数写入本地文件。
<?
@session_start();
$counter = intval(file_get_contents("counter.dat"));
if(!$_SESSION['jb200.com'])
{
$_SESSION['jb200.com'] = true;
$counter++;
$fp = fopen("counter.dat","w");
fwrite($fp, $counter);
fclose($fp);
}
?>
共访问:
<?php echo "$counter";?>次