计数器
本教程属于原载,转载请注明出自网页教学网
说明:
实现原理是:利用PHP的功能函数去读取文本文件的数据,从而实现数据的统计。
1. 新建一个文件取名为:counter.php。代码如下:
//选择 counter.txt文本文件
$counter_file = ("counter.txt");
//打开文本文件
$visits = file($counter_file);
//自动加1
$visits[ 0]++;
//这个点击自动记录
$fp = fopen($counter_file , "w");
//写入counter.txt文件中,从而记录了
fputs($fp , "$visits[ 0]");
//关闭文件
fclose($fp);
//显示次数
echo $visits[0];
?>
2. 把下面的代码代码放到你想显示点击次数的地方,达到文件显示目的。
include ("counter.php");
?>
3. 最后新建一个文件counter.txt.修改其权限为 777。
简单的计数器就实现了。

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 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

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

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