<?php 
include('myFunction.php');
header("content-type:text/html;charset=utf-8");
$c_file="counter.txt";
//如果文件不存在就创建文件,并设定初始值位0
if(!file_exists($c_file)){
$myfile=fopen($c_file, "w");
fwrite($myfile,"0");
fclose($myfile);
}
$t_num=file($c_file);
if($_COOKIE["date"]!=date('Y年m月d日')){
$t_num[0]++;
$myfile=fopen($c_file, "w");
fwrite($myfile, $t_num[0]);
fclose($myfile);
setcookie("date",date('Y年m月d日'),time()+60*60*24);
}


//读取出文件中的数
echo "欢迎 您是第";
$file=fopen("counter.txt","r") or exit("无法打开文件!");
while (!feof($file))
{
$ch=fgetc($file);
if($ch!=null){
    echo "<img src='images\\".$ch.".png'>";
   }
}
    echo "位访客";
fclose($file);


?> php 简单的访问量小程序_php