readdir()读取不存在的文件“。”和“......”

时间:2013-10-06 18:16:20

标签: php file

我是一名基本的php程序员,拥有一个包含用户和个人资料图片的简单网站。

有一个名为ppic的文件夹(个人资料图片)。

当我在php.net site上使用readdir()时,会打印出两个不存在的文件。

如果我将echo "there was a match - $entry<br>;置于while循环中且$entry为文件名,则打印出来:

there was a match - .
there was a match - ..
there was a match - Autumn Leaves.jpg
there was a match - Creek.jpg
there was a match - Toco Toucan.jpg

我在文件夹中只有三个文件:“Autumn Leaves.jpg”,“Creek.jpg”和“Toco Toucan.jpg”。

我对电脑不太好,所以我不知道那些点是什么意思。

有人可以向我解释这些吗?

1 个答案:

答案 0 :(得分:5)

学习UNIX基础知识:(以及其他常见的文件系统处理)

.是指向当前文件夹的虚拟符号链接(例如./Creek.jpg已解决,与Creek.jpg相同)

..是父文件夹的虚拟符号链接。

要隐藏它们,只需通过$file !== '.' && $file !== '..'手动排除。

相关问题