作者ast9869 (该照顾别人老婆吗)
看板PHP
标题Re: [请益] 为什麽我这样写的时间纪录都是一样的 =.=
时间Sun Jan 1 19:18:11 2006
※ 引述《question7 (傻孩子才会马哈哈)》之铭言:
: 我想要写一个会记录时间的留言板
: 但是写了之後
: 发现时间变成最後一笔资料写入的时间 =.=
: 而且时间次数会比资料笔数多一
: ex:
: 2006/01/01 17:20:53
: CCC2006/01/01 17:20:53
: BBB2006/01/01 17:20:53
: AAA2006/01/01 17:20:53
: 下面附上我的程式码
: 希望有大大可以帮我看一下该如何修改
: thanx ~
: ==========================以下是程式码============================
: <?php
$msg = $_POST["msg"];
if (strlen($msg) >= 2)
{
$hex = "0123456789ABCDEF";
$msg .= date("Y/m/d H:i:s")."\n";
appendf($msg);
$x = readf();
$y = array_reverse($x);
foreach ($y as $i)
{
echo "<FONT COLOR=#",$hex[rand(0,15)].$hex[rand(0,15)].
$hex[rand(0,15)].$hex[rand(0,15)].$hex[rand(0,15)].
$hex[rand(0,15)],">",stripslashes(strip_tags($i)),"<BR>\n";
}
}
function appendf($msg)
{
$handle=fopen("C:\\AppServ\www\msg.dat", "a");
fputs($handle,$msg);
fclose($handle);
}
: function readf() {
: $handle=fopen("C:\\AppServ\www\msg.dat", "r");
: $a=array();
: while (!feof($handle)) {
: $s=rtrim(fgets($handle,80));
: array_push($a,$s);
: };
: fclose($handle);
: return $a;
: }
: ?>
: <A HREF="msg.htm">回上一页</A>
试试吧~我没试过。
--
█████████████████
█ ████████████████
█████████████████
█ ████████████████
█████████████████
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.73.222.220