php简单的在线聊天室程序
php教程简单的在线聊天室程序
index.php
<title> 在线聊天 </title> <!-- frames --> <frameset rows="70%,*" border="0"> <frame name="top" src="_b.php" marginwidth="0" marginheight="0" scrolling="yes" frameborder="NO" noresize> <frame name="bottom" src="_a.php" marginwidth="0" marginheight="0" scrolling="no" frameborder="no" noresize> </frameset>
_a.php
class="brush:php;"><html> <title> 聊天室 </title> <body TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 > <?php $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,"<font color="blue">".$person."</font> in <font color="red">".$time."</font>  s教程ays that  <b>".$msg."</b><br>"."n"); for ($i =0;$i<$tot;++$i){ if ($i>50) break; fwrite($fp,$oldmsg[$i]); } } <TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="left" bgcolor="#666666"> <td height="20"> </td></tr> <tr bgcolor="#FFCC66"> <td width="1" height="4" ></td> </tr> </TABLE> <table width="100%" border=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF"> <tr bgcolor="#666666"> <td align="left"> <table width="100%" height="500" boder=0 cellspacing=0 cellpadding=0 bgcolor="#EFEFEF"> <tr align="left"> <td valign="top"> <font size="-1" color="#666666"> <table width = "100%" border = "0"> <tr> <form action="_a.php" method = "post"> <td align="left"> <font size="-1">昵称:</font> <input type="text" name="person" size="12" maxlength="80" value="<?php echo $person;"> <br> <font size="-1"></font> <textarea type="textarea" name="message" rows="9" cols="150" size = 100></textarea> <input type="submit" value="发言"> </td> </form> </tr> </table> </font> </td> </tr> </tr> </table> </td> </tr> </table> </body> </html>
_b.php
class="brush:php;"><html> <head> <title> 聊天室 </title> </head> <META HTTP-EQUIV=Refresh CONTENT="5; URL=_b.php"> <body bgcolor="#EFEFEF"> <?php $handle=fopen("msg.txt","r"); //$oldmsg = array(); while ($content = fgets($handle)){ //$oldmsg[] = $content; //++$tot; echo $content; } </body> </html>
永久链接:
转载随意!带上文章地址吧。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

如何解决PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory在使用PHP开发过程中,我们经常会遇到一些文件操作的问题,其中之一就是"PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory

如何解决PHPWarning:fopen():SSLoperationfailedinfile.phponlineX在PHP编程中,我们经常使用fopen函数来打开文件或者URL,并进行相关操作。然而,在使用fopen函数时,有时候会遇到类似于Warning:fopen():SSLoperationfailedinfile.p

如何解决PHPWarning:fopen():failedtoopenstream:Permissiondenied在开发PHP程序的过程中,我们常常会遇到一些报错信息,比如PHPWarning:fopen():failedtoopenstream:Permissiondenied。这个错误通常是由于文件或目录权限不正

在Matlab中,fopen函数用于打开文件并返回文件标识符,以便后续对文件进行读取或写入操作。根据需要选择适当的权限选项来打开文件,并在操作完成后及时关闭文件。需要注意的是,打开文件后需要确保在不再需要文件时及时关闭文件,以释放系统资源。另外,如果文件打开失败或操作出错,可以通过错误处理机制进行相应的处理。

在PHP开发中,对文件的操作是非常常见的。一般情况下,我们需要进行文件的读取、写入、删除等操作。其中,文件的读取可以使用fopen函数和fread函数,文件的写入可以使用fopen函数、fwrite函数和fclose函数。本文将介绍php如何使用fopen、fwrite和fclose进行文件操作。一、fopen函数fopen函数用于打开文件,它的语法如下:r

C中的fopen()方法用于打开指定的文件。我们举个例子来理解一下问题语法FILE*fopen(filename,mode)以下是使用fopen()打开文件的有效模式:‘r’、‘w’、‘a’、‘r+’、‘w+’、‘a+’。详细信息请访问C库函数-fopen()

如何解决PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectoryinfile.phponlineX在开发和运行PHP程序时,我们有时会遇到PHPWarning:fopen():failedtoopenstream:Nosuchfileor

可以使用readonly属性、disabled和readwrite属性来设置textarea只读。详细介绍:1、readonly属性,readonly属性的值为readonly;2、disabled属性,<textarea>元素的内容将无法更改,因为disabled属性的值为disabled;3、readwrite属性,<textarea>元素的内容可以更改等等。
