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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
