PHP:什么作用.和.dir->read() 输出中的平均值


php: what does . and .. mean in the output of dir->read()

<?php
$d = dir('css');
echo "Handle: " . $d->handle . "<br>";
echo "Path: " . $d->path . "<br>";
while (($file = $d->read()) !== false){
  echo "filename: " . $file . "<br>";
}
$d->close();
?>

结果:

Handle: Resource id #4
Path: css
filename: .
filename: ..
filename: css
filename: img
filename: index.html
filename: js
filename: lightbox

问题:

结果,...是什么意思?

.

当前目录,..是向上的。大多数代码示例都有if-statement跳过它们。

以下是PHP文档中的示例:

http://php.net/manual/en/function.readdir.php#example-2318

即使在文档中,它也会显示要忽略的代码。

.是对

当前目录的引用,..是上一级的目录。

例如,在 linux 中更改目录时,您可以使用 cd .. 向上访问一个目录。

表示 Linux 系统中的当前目录

.. 表示 Linux 系统中的父目录