| 最简单的留言板(PHP) |
|
| 作者:未知 文章来源:网络收集 点击数: 更新时间:2006-3-29 15:22:25
|
ens file or URL Description int fopen ( string filename, string mode [, int use_include_path])
flock (PHP 3>= 3.0.7, PHP 4 >= 4.0.0) flock -- Portable advisory file locking Description bool flock ( int fp, int operation [, int wouldblock])
fwrite (PHP 3, PHP 4 >= 4.0.0)
fwrite -- Binary-safe file write Description int fwrite ( int fp, string string [, int length])
fclose (PHP 3, PHP 4 >= 4.0.0)
fclose -- Closes an open file pointer Description bool fclose ( int fp)
关于函数的具体阐述请查阅PHP手册,如果你还没有,请 screen.width-600)this.style.width=screen.width-600;">_blank href=http://www.php.net/distributions/manual/php_manual_en.chm>http://www.php.net/distributions/manual/php_manual_en.chm下载。现在,我们就把留言存起来:
/////////////////////////////////////////////// // This web will save the words U leave.. // /////////////////////////////////////////////// $ft=fopen('words.txt',"a+"); flock($ft,LOCK_EX); $data=$texttitle."\n".$textcontent; fwrite($ft,$data); $ok=fclose($ft); if($ok) echo "save the txet successfully..."; ?> 需要注意的是flock($ft,LOCK_EX)这一句并不是可有可无的,它在对文件进行写操作之前锁定了文件,这样就有效地避免了多个用户同时对该文件进行操作而出现的错误。看看目录里边,是不是多出来了一个名叫words.txt的文本文件呢?打开一看,果然是我们刚才存放的数据。 就这样,SAVE.PHP也实现了,接下来就是显示留言了,最简单地,你可以让ECHO.PHP直接显示words.txt,方法是使用框架或者重定向。 下面我们分别用框架和重定向的方法来实现ECHO.PHP
<-- /// ECHO.PHP: Use a fram to show the file words.txt ////////////////////上一页 [1] [2] [3] 下一页
|
|
[ 收藏此页到: 天天|和讯|博采|ViVi|狐摘|我摘|天极 ] 文章录入:kinda 责任编辑:kinda |
|
上一篇文章: C语言库函数(E类字母) 下一篇文章: Win32教程8-菜单 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |