Re: [問題] 有關計數器
修改如下
in a.htm
<?php
include("count.php");
?>
in b.htm
<?php
include("countpic.php");
for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
echo ("<img src=images/counter/$counter_array[$array_id].gif></img>");
}
?>
count.php檔如下:
<?php
$countfile = "counter.dat";
if (($fp = fopen($countfile, "r+")) == false) {
printf ("Open file %s failed!",$countfile);
exit;
}
else
{
$count = fread ($fp,filesize($countfile));
$count = $count + 1;
fclose ($fp);
$fp = fopen($countfile, "w+");
fwrite ($fp,$count);
fclose ($fp);
}
?>
countpic.php檔如下:
<?php
$countfile = "counter.dat";
$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;
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.151.64
推
140.122.140.202 05/05, , 1F
140.122.140.202 05/05, 1F
Web_Design 近期熱門文章
PTT數位生活區 即時熱門文章