search
Homephp教程php手册PHP website statistics simple version, text database

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:
PHP website statistics simple version, text database
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? !
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

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

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools