图片计数器实例教程

以了计数器的可观,大家平常会用图片做总计的数字1,2到10大家如若做0,9的图样数字,然后用上面包车型客车措施就来做出美貌的流量计出来啊。

 代码如下

$fp = fopen ($countfile, rState of Qatar; //以只读情势张开文件$array_count = 1;
//定义三个象征数组成分地方的变量,上边要用while (! feof($fp))
{$current_number = fgetc($fp);$counter_array[澳门新葡萄京官网注册,$array_count] =
$current_number;$array_elements = count
($counter_array);$array_count = $array_count + 1;}//彰显代码echo
(table border=0 height=5 align=lefttrtd align=center接待您,第State of Qatar;

<html>
<head>
<title>计数器</title>
<head>
<body>

for ($array_id = 1;$array_id $array_elements; ++ $array_id) {echo
(img src=./img/$counter_array[$array_id].gif align=absmiddle);}

<?PHP
$countfile = “counter.txt”;
//定义流速計写入的公文是当前目录下的www.111cn.net.txt文本中,然后我们理应测量检验该文件是或不是展开
if (($fp = fopen($countfile, “r+”)) == false) {
 //用读写情势张开文件,若不能够开垦就退出
 printf (“Open file %s failed!”,$countfile);
 exit;
}
else
{
//假若文件能够健康展开,就读入文件中的数据,若是是1
$count = fread ($fp,10);
//读取10位数据
$count = $count + 1;
//count ++
fclose ($fp);
//关闭当前文件
$fp = fopen($countfile, “w+”);
//以覆盖方式张开文件
fwrite ($fp,$count);
//写入加1后的新数据
fputs($fp,$fg);
//显示计数结果
// 数显
echo “<div align=center><font
size=5>计数十三回数:$count</font><br>”;

// 图形形式计数
$fp = fopen ($countfile, “r”卡塔尔(قطر‎; //以只读方式张开文件
$array_count = 1; //定义三个意味着数组成分地点的变量,下边要用
while (! feof($fp)) {
$current_number = fgetc($fp);
$counter_array[$array_count] = $current_number;
$array_elements = count ($counter_array);
$array_count = $array_count + 1;
}
echo “<div align=center><font
size=5>计多次数www.111cn.net:”;
for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
echo “<img src=countimg/”.$counter_array[$array_id].”.gif>”;
}
echo “</font>”;

fclose ($fp);
//并关闭文件
}

?>

</body>
</html>

发表评论

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