本文实例讲述了PHP文件操作之小型留言本。分享给大家供大家参考。具体如下:
PHP;">
PHP
$path = "DB/"; //定义路径
$dr = opendir($path); //打开目录
while($filen = readdir($dr)) //循环读取目录中的文件
{
if($filen != "." and $filen != "..")
{
$fs = fopen($path.$filen,"r");
echo "标题:".fgets($fs)."
"; echo "作者:".fgets($fs)."
"; echo "内容:
"; fclose($fs); } } closedir($dr) //关闭目录 ?>
"; echo "作者:".fgets($fs)."
"; echo "内容:
".fread($fs,filesize($path.$filen)).""; echo "
"; fclose($fs); } } closedir($dr) //关闭目录 ?>