电脑安全

您当前的位置:主页 > 电脑安全 >

php图片计数器代码-网络编程

来源:[db:来源]标题:   好了    编辑:电脑技术全能网 时间:2019-09-20 06:23

原标题:php图片计数器代码-网络编程
   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();?>好了上面咱们来看看show.php输入文件.<?php$count = substr(file_get_contents('count.txt'),7);$con_len =strlen($count);for($i=$con_len-1;$i>=0;$i--){echo"document.write('<img src=../counter/counter/".substr($count,$i,1).".jpg />');"; }?>如许咱们的输片计数器就进去了,留神哦.echo"document.write('<img src=../counter/counter/".substr($count,$i,1).".jpg />');";必需以document.write输入哦,由于咱们上面要用js情势挪用哦.上面在txt.html如许挪用show.php文件就行了以下.<script src='show.php'></script>等吧,咱们教程就OK了.本站原创转请说明: www.dnjishu.com/phper/php.html

上一篇:取得文件扩展名方法-网络编程

下一篇:没有了