php写的简易聊天室代码 _爱资料
主页 > 编程资料 > PHP >
发布时间:2015-12-29 作者:网络 阅读:205次
index.php
复制代码 代码如下:

<BR>在线聊天 <BR>









_a.php
复制代码 代码如下:

<BR>聊天室 <BR>

$person = @$_POST[person];
$msg = @$_POST[message];
if ($person!="" && $msg!=""){
$handle = fopen("msg.txt","r");
$tot = 0;
$oldmsg = array();
while ($content = fgets($handle)){
$oldmsg[] = $content;
++$tot;
}
fclose($handle);
unlink("msg.txt");
$fp = fopen("msg.txt","a+");
$time = date("h:i");
fwrite($fp,"".$person." in ".$time."  says that  ".$msg."
"."\n");
for ($i =0;$i<$tot;++$i){
if ($i>50) break;
fwrite($fp,$oldmsg[$i]);
}
}
?>




























昵称:













_b.php
复制代码 代码如下:


<BR>聊天室 <BR>



$handle=fopen("msg.txt","r");
//$oldmsg = array();
while ($content = fgets($handle)){
//$oldmsg[] = $content;
//++$tot;
echo $content;
}
?>



关键字词: