2010-05-13 102 views
0

我有以下幾個循環遍歷目錄中的文件並回顯文件名。但是,當我使用實時路徑時,它不返回任何內容。我在做什麼錯了: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。

回答

3

你想用

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

否則它將在當前工作目錄。

+0

太棒了,非常感謝你!這工作。 – Abs 2010-05-13 23:29:00