php图片计数器代码

php
文件计数据器+mysql双保证,这是上次升格版了,上次流量大太平日出难题明天涂改回复了.

php图片计数器代码,他的落实情势是先用程序把数字保存到多少个txt文件或数据库,然后再读取,当然数字大家要做0-9的图样啊.好了下边大家来探视总括代码吧.

?phprequire_once(../inc/connect.php);Class Sit_count{ public $FileName
= ‘count.txt’; function Count_add(){if(file_exists($this-FileName)
){$Temp = file_get_contents($this-FileName);$Array =
explode(=,$Temp);if(count($Array) != 2){$Tmp
=’mytext=’.$this-Tcount();}else{$Total = $Array[1]+1;$Tmp
=$Array[0].’=’.$Total;}$T =
@fopen($this-FileName,’w’);if($T){fwrite($T,$Tmp);fclose($T);}mysql_query(update
wk_count set count_bak =count_bak+1 where id=1);}else{echo ‘!
file_exists’;} } function Tcount(){ $result =mysql_query(Select *
from wk_count where id =1 ) or die(mysql_error());$rs
=mysql_fetch_array($result);return $rs[‘count_bak’]; }} $tp = new
Sit_count; $tp-Count_add(卡塔尔国;?本站原创转发注脚

?phprequire_once(../inc/connect.php);Class Sit_count{ public $FileName
= ‘count.txt’; function Count_add(){if(file_exists($this-FileName)
){$Temp = file_get_contents($this-FileName);$Array =
explode(=,$Temp);if(count($Array) != 2){$Tmp
=’mytext=’.$this-Tcount();}else{$Total = $Array[1]+1;$Tmp
=$Array[0].’=’.$Total;}$T =
@fopen($this-FileName,’w’);if($T){fwrite($T,$Tmp);fclose($T);}mysql_query(update
wk_count set count_bak =count_bak+1 where id=1);}else{echo ‘!
file_exists’;} } function Tcount(){ $result =mysql_query(Select *
from wk_count where id =1 ) or die(mysql_error());$rs
=mysql_fetch_array($result);return $rs[‘count_bak’]; }} $tp = new
Sit_count; $tp-Count_add(卡塔尔(قطر‎;?好了上面大家来探望show.php输出文件.

?php$count = substr(file_get_contents(‘count.txt’),7);$con_len
=strlen($count);for($i=$con_len-1;$i=0;$i–){echodocument.write(‘img
src=../counter/counter/.substr($count,$i,1)..jpg /’);; }

?

那样我们的输片流量计就出去了,注意哦.echodocument.write(‘img
src=../counter/counter/.substr($count,$i,1卡塔尔国..jpg
/’卡塔尔国;;必需以document.write输出哦,因为大家上面要用js格局调用哦.

上边在txt.html那样调用show.php文件就行了如下.

script src=’show.php’/script

等啊,我们学科就OK了.

本站原创转请申明:

发表评论

电子邮件地址不会被公开。 必填项已用*标注