首頁  >  文章  >  後端開發  >  php写的简易聊天室代码_PHP教程

php写的简易聊天室代码_PHP教程

WBOY
WBOY原創
2016-07-21 15:29:31657瀏覽

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;$iif ($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;
}
?>



php写的简易聊天室代码_PHP教程

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/323403.htmlTechArticleindex.php 复制代码 代码如下: html headTitle 在线聊天 /title/head !-- frames -- frameset rows="70%,*" BORDER="0" frame name="top" src="_b.php" marginwidth="0" marginheigh...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn