關於檔案遍曆的有關問題

來源:互聯網
上載者:User
關於檔案遍曆的問題
function file_list($path)
{
$paths = iconv("UTF-8", "gb2312", $path);
if ($handle = opendir($paths))//開啟路徑成功
{
while (false !== ($file = readdir($handle)))//迴圈讀取目錄中的檔案名稱並賦值給$file
{
echo $file.'
';
//在遍曆每個檔案目錄時會輸出 . .. 這三點是哪來的
if ($file != "." && $file != "..")//也就是這句判斷的三點
{
if (is_dir($paths."/".iconv("gb2312","UTF-8",$file)))
{
// echo $path.": ".$file."
";//去掉此行顯示的是所有的非目錄檔案
file_list($paths."/".iconv("gb2312","UTF-8",$file));
}
else
{
// echo $paths.": ".iconv("gb2312","UTF-8",$file)."
";
}
}
}
}
}
$path = "D:\A";
file_list($path);
------解決思路----------------------
if ($file != "." && $file != "..")//這三點是哪來的?
$file != "." 不是目前的目錄標誌
$file != ".." 不是目前的目錄標誌

目錄在電腦的檔案系統中也是檔案,.和 .. 在目錄檔案中標識特定的目錄項
------解決思路----------------------
linux下目前的目錄和上級目錄
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.