>  기사  >  백엔드 개발  >  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으로 문의하세요.