宝哥软件园

PHP实现了通过文本文件统计页面访问量的功能

编辑:宝哥软件园 来源:互联网 时间:2021-08-27

本文说明了PHP如何通过文本文件统计页面访问量。分享给大家参考,如下:

代码

index.php

?PHP session _ start();If($_SESSION[temp]==''){ //判断$_SESSION[temp]=' '的值是否为空,其中temp为用户自定义变量if (($ FP=fopen ('counter.txt ',' r ')==false){ echo '未能打开文件;}else{ $counter=fgets($fp,1024);//读取文件中的数据fclose($ FP);//关闭文本文件$ counter//计数器增加1 $fp=fopen('counter.txt ',' w ');//以书面形式打开文本文件!- fputs($fp,$ counter);//增加新统计1 fclose($ FP);}//关闭文本$ _ SESSION[temp]=1;//登录后,$_SESSION[temp]的值不为空,那么赋值1}?html healtheta http-equiv=' Content-Type ' Content=' text/html;Charset=gb2312 '按文本文件/titlestyle类型划分的页面访问量标题统计='text/css '!-. STYLe 1 { font-size : 12px;font-weight:粗体;}正文{ margin-left : 0px;边距-top : 0px;右边距: 0px;边距-底部: 0px;} . STYLe 2 { color : # ff 0000;font-weight:粗体;}-/style/head dytable width=' 995 ' height=' 809 ' border=' 0 ' align=' center ' cell padding=' 0 ' cell spacing=' 0 ' background=' images/BG . jpg ' tr TD width=' 131 ' height=' 215 '/TD TD TD width=' 714 '/TD TD TD width=' 128 '/TD/tr TD TD height=' 323 '/TD TD align=' center ' valgn=' top ' table width=' 660 ' 战略发展潜力巨大/p p class=' style 1 ' strong公司愿景/strong:成为拥有核心技术和产品的高科技公司,在某些领域拥有领先的市场地位。 /p p class=' style 1 ' strong核心价值观/strong:永远保持创业激情,天天向上,包容失败,鼓励创新,充分信任,平等交流。/p/TD/tr/tr TD高度=' 40 ' align=' center ' img src=' http : GD 1 . PHP '/TD/tr/table/TD/TD/tr TD/TD/TD/TD/tr/tablep/p/BOdy/HTMlgd 1 . PHP

?Php//如果($ FP=fopen ('counter.txt ',' r ')==false){ echo '未能打开文件,则以图形形式输出数据库中的记录数!';}else{ $counter=fgets($fp,1024);fc lose(FP美元);//通过GD2函数创建画布$im=imagecreate(240,24);$gray=imagecolorallocate($im,255,255,255);$color=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));//定义字体颜色//输出汉字$text=iconv('gb2312 ',' utf-8 ','网站访问量: ');//转换指定的中文字符串$ $font='Fonts/FZHCJW。' TTF ';imagettftext($im,14,0,20,18,$color,$font,$ text);//输出中文//输出网站imagestring的访问量($ im,5,160,5,$ counter,$ color);image png($ im);image destroy($ im);}?二.运营成果

更多对PHP相关内容感兴趣的读者可以查看本网站的话题:《php文件操作总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》、《php常见数据库操作技巧汇总》、0103010。

希望本文对PHP编程有所帮助。

更多资讯
游戏推荐
更多+