opendir为什么不认识根目录?
<?php
$dir = "/etc/php5/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>
以上是手册中的例子
为什么我这样使用就什么都不显示呢?(目录是存在的)
我把
$dir = "/etc/php5/";
改成
$dir = "./etc/php5/";
就是把路径加上一个点,这种方式就可以了,为什么?我的文件就是在根目录下,这样有点没点不是一样吗?
php版本5.3