php文本图片计数器实例

以了流速计的精髓,大家日常会用图片做总结的数字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款待您,第卡塔尔国;

<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>计数11次数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>

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图