Realize total visits, visits this month, yesterday's visits, today's visits statistics, use text storage, simple and easy to use
Automatically create a text database and save this php in the same directory. The display effect is as shown below:
Calling method:
<?php <code class="prettyprint linenums lang-php"><?php <br />
error_reporting(0);<br>
header ( "Content-type: text/html; charset=utf-8" );<br>
//设置数据文件路径<br>
$file = dirname(__FILE__).'/tongji.db';<br>
$data = unserialize(file_get_contents($file));<br>
//设置记录键值<br>
$total = 'total';<br>
$month = date('Ym');<br>
$today = date('Ymd');<br>
$yesterday = date('Ymd',strtotime("-1 day"));<br>
$tongji = array();<br>
// 总访问增加<br>
$tongji[$total] = $data[$total] 1;<br>
// 本月访问量增加<br>
$tongji[$month] = $data[$month] 1;<br>
// 今日访问增加<br>
$tongji[$today] = $data[$today] 1;<br>
//保持昨天访问<br>
$tongji[$yesterday] = $data[$yesterday];<br>
//保存统计数据<br>
file_put_contents($file, serialize($tongji));<br>
//输出数据<br>
$total = $tongji[$total];<br>
$month = $tongji[$month];<br>
$today = $tongji[$today];<br>
$yesterday = $tongji[$yesterday]?$tongji[$yesterday]:0;<br>
echo "document.write('总访问 {$total}, 本月 {$month}, 昨日 {$yesterday}, 今日 {$today}');";
error_reporting(0);
header ( "Content-type: text/html; charset=utf-8" );
//Set data file path $file = dirname(__FILE__).'/tongji.db'; $data = unserialize(file_get_contents($file)); //Set record key value $total = 'total'; $month = date('Ym'); $today = date('Ymd'); $yesterday = date('Ymd',strtotime("-1 day")); $tongji = array(); // Total visits increased $tongji[$total] = $data[$total] 1; // Increased visits this month $tongji[$month] = $data[$month] 1; // Increased visits today $tongji[$today] = $data[$today] 1; //Keep yesterday’s visit $tongji[$yesterday] = $data[$yesterday]; //Save statistics file_put_contents($file, serialize($tongji)); //Output data $total = $tongji[$total]; $month = $tongji[$month]; $today = $tongji[$today]; $yesterday = $tongji[$yesterday]?$tongji[$yesterday]:0; echo "document.write('Total visits {$total}, this month {$month}, yesterday {$yesterday}, today {$today}');"; Yunqi Conference Beijing Station: It’s rare for Alibaba’s technical experts to appear on camera. More than 100 of them came this time? !
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools