简体   繁体   English

RealPath返回一个空字符串

[英]RealPath returns an empty string

I have the following which just loops through the files in a directory and echo the file names. 我有以下内容,它们仅循环遍历目录中的文件并回显文件名。 However, when I use realpath, it returns nothing. 但是,当我使用realpath时,它什么也不返回。 What am I doing wrong: 我究竟做错了什么:

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);
}

Thanks all for any help on this. 感谢所有对此的帮助。

~I am on a windows machine, running php 5.3 and apache 2.2. 〜我在Windows机器上,运行php 5.3和apache 2.2。

You want to use 你想用

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

else it will look in the current working dir. 否则它将在当前工作目录中查找。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM