RealPath返回一个空字符串
问题描述:
我有以下几个循环遍历目录中的文件并回显文件名。但是,当我使用实时路径时,它不返回任何内容。我在做什么错了: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。
答
你想用
echo realpath($font_path . DIRECTORY_SEPARATOR . $file);
否则它将在当前工作目录。
太棒了,非常感谢你!这工作。 – Abs 2010-05-13 23:29:00