znznzn333
注册会员

UID 112524
精华
0
积分 146
帖子 99
金钱 146 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2008-3-3
状态 离线
|
[广告]: q
m
可能又是很白痴的问题.谁能帮我解决?
我做了一个图形的计数器不知道为什么图形出不来.
做了三个文件分别是count.php count.inc count.dat 和 img的文件夹里面有放0~9的gif的图片.
count.php的代码如下:
<?php
require("count.inc");
?>
<html>
<head>
<title>欢迎进入测试我的计数器</title>
</head>
<body>
<p> 欢迎进入我的网站</p>
您是本站的第<?php counter(); ?>个访问者.<br>
</body>
</html>
count.inc的代码如下:
<?php
function counter()
{
$max_len=8;
$counterfile="count.dat";
if(!file_exists($counterfile))
{
$counter =0;
$cf=fopen($counterfile,"w");
flock($cf,3);
fputs($cf,"0");
fclose($cf);
}
else
{
$cf=fopen($counterfile,"r");
flock($cf,3);
$counter=trim(fgets($cf,$max_len));
fclose($cf);
}
if(session_is_registered("in")==false)
{
$counter++;
$cf=fopen($counterfile,"w");
flock($cf,3);
fputs($cf,$counter);
fclose($cf);
}
$counter_len=strlen($counter);
for($i=1;$i<=($max_len-$counter_len);$i++)
{
echo"<img src='img/0.gif'>";
}
for ($i=1; $i<=$counter_len;$i++)
{
echo"<img src='img/". substr($counter,$i-1,1).".gif'>";
}
}
?>
|
|