RealPath返回一个空字符串

时间:2010-05-13 23:21:39

标签: php file

我有以下内容,它只是遍历目录中的文件并回显文件名。但是,当我使用realpath时,它什么都不返回。我做错了什么:

if ($handle = opendir($font_path)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != ".." && $file != "a.zip") {

            echo $file.'<br />';//i can see file names fine

            echo realpath($file);// return empty string?!

        }
    }
    closedir($handle);
}

感谢大家对此提供的任何帮助。

〜我在Windows机器上运行php 5.3和apache 2.2。

1 个答案:

答案 0 :(得分:3)

您想要使用

echo realpath($font_path . DIRECTORY_SEPARATOR . $file);

否则它会查看当前正在运行的目录。

相关问题