Php RealPath返回一个空字符串

Php RealPath返回一个空字符串,php,file,Php,File,我有以下内容,它只是在目录中的文件中循环并回显文件名。但是,当我使用realpath时,它不返回任何内容。我做错了什么: if ($handle = opendir($font_path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "a.zip") { echo $f

我有以下内容,它只是在目录中的文件中循环并回显文件名。但是,当我使用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);
}
if($handle=opendir($font\u path)){
while(false!=($file=readdir($handle))){
如果($file!=“&&&$file!=”。“&&&$file!=“a.zip”){
echo$file.“
”;//我可以很好地看到文件名 echo realpath($file);//返回空字符串?! } } closedir($handle); }
谢谢大家在这方面的帮助

~z~我在一台windows计算机上,运行php 5.3和apache 2.2。

您想使用吗

echo realpath($font_path . DIRECTORY_SEPARATOR . $file);
否则它将在当前工作目录中查找。

您要使用的

echo realpath($font_path . DIRECTORY_SEPARATOR . $file);
否则它将在当前工作目录中查找