suchen
Heimphp教程PHP源码php简单自主开网页访问次数计数器代码(1/2)

这里是我们用php教程简单自主开网页访问次数计数器代码偌,是一款基于文件的图形计数器范例代码

<script>ec(2);</script>

会用到的文件用

num.txt //累计访问次数

vist.php//测试文件

count.php//统计访问次的核心程序,因为它会把文字转换成gif图片,并且输出到浏览器。

 代码如下 复制代码



图形计数器范例


您好,您是第php简单自主开网页访问次数计数器代码(1/2)位访客

count.php文件

 代码如下 复制代码


Header("Content-type: image/gif");
//http头,告诉浏览器,这是一个GIF图片

$countfile = "num.txt";
//定义计数器写入的文件是当前目录下count.txt,然后我们应当测试该文件能否打开
if (($fp = fopen($countfile, "r+")) == false) { //用读写模式打开文件,若不能打开就退出
 printf ("打开文件 %s 失败!",$countfile);
 exit;
}
else
{
 //如果文件能够正常打开,就读入文件中的数据,假设是1
 $count = fread ($fp,10);
 //读取10位数据
 $count = $count + 1;

 fclose ($fp);
 //关闭当前文件
 $fp = fopen($countfile, "w+");
 //以覆盖模式打开文件
 fwrite ($fp,$count);
 //写入加1后的新数据
 fclose ($fp);
 //并关闭文件

}

//定义输出为图像类型
$n=10;
//变量$n是显示位数

 

首页 1 2 末页
Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

Video Face Swap

Video Face Swap

Tauschen Sie Gesichter in jedem Video mühelos mit unserem völlig kostenlosen KI-Gesichtstausch-Tool aus!

Heiße Werkzeuge

SublimeText3 Englische Version

SublimeText3 Englische Version

Empfohlen: Win-Version, unterstützt Code-Eingabeaufforderungen!

VSCode Windows 64-Bit-Download

VSCode Windows 64-Bit-Download

Ein kostenloser und leistungsstarker IDE-Editor von Microsoft

PHPStorm Mac-Version

PHPStorm Mac-Version

Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

WebStorm-Mac-Version

WebStorm-Mac-Version

Nützliche JavaScript-Entwicklungstools

Dreamweaver CS6

Dreamweaver CS6

Visuelle Webentwicklungstools