您的位置:首页 > 其它

列出目录中的所有文件

2008-05-27 11:10 204 查看
<?php
// 注意在 4.0.0-RC2 之前不存在 !== 运算符

if ($handle = opendir('C:/AppServ/www'))
{
echo "Directory handle: $handle ";
echo "/n";
echo "Files:/n";

/* 这是正确地遍历目录方法 */
//readdir -- 从目录句柄中读取条目
while (false !== ($file = readdir($handle)))
{
echo "$file/n";
}

/* 这是错误地遍历目录的方法 */
while ($file = readdir($handle))
{
echo "$file/n";
}

closedir($handle);

}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: