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脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

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

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

如何解決PHPWarning:fopen():SSLoperationfailedinfile.phponlineX在PHP程式設計中,我們經常使用fopen函數來開啟檔案或URL,並進行相關操作。然而,在使用fopen函數時,有時候會遇到類似Warning:fopen():SSLoperationfailedinfile.p

如何解決PHPWarning:fopen():failedtoopenstream:Permissiondenied在開發PHP程式的過程中,我們常常會遇到一些報錯訊息,例如PHPWarning:fopen():failedtoopenstream:Permissiondenied。這個錯誤通常是因為檔案或目錄權限不正

如何解決PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory在使用PHP開發過程中,我們常常會遇到一些檔案操作的問題,其中之一就是"PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory

在Matlab中,fopen函數用於開啟檔案並傳回檔案標識符,以便後續對檔案進行讀取或寫入操作。根據需要選擇適當的權限選項來開啟文件,並在操作完成後及時關閉文件。需要注意的是,打開文件後需要確保在不再需要文件時及時關閉文件,以釋放系統資源。另外,如果檔案開啟失敗或操作出錯,可以透過錯誤處理機制進行對應的處理。

C中的fopen()方法用來開啟指定的檔案。我們舉個例子來理解一下問題語法FILE*fopen(filename,mode)以下是使用fopen()開啟檔案的有效模式:'r'、'w'、'a'、'r+'、'w+'、' a+'。詳細資訊請存取C庫函數-fopen()

在PHP開發中,對文件的操作是非常常見的。一般情況下,我們需要進行檔案的讀取、寫入、刪除等操作。其中,檔案的讀取可以使用fopen函數和fread函數,檔案的寫入可以使用fopen函數、fwrite函數和fclose函數。本文將介紹php如何使用fopen、fwrite和fclose進行檔案操作。一、fopen函數fopen函數用來開啟文件,它的語法如下:r

如何解決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>元素的內容可以更改等等。
