PHP遍历文件夹下的所有文件和文件夹

\n";
    while ($file = $mydir->read()) {
        if (is_dir("$dir/$file") AND $file != "." AND $file != "..") {
            echo "
  • $file
  • "; tree("$dir/$file"); } else { echo "
  • $file
  • \n"; } } echo "\n"; $mydir->close(); } echo "

    目录为粉红色


    \n"; tree("e:/www"); function tree($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ((is_dir($dir . "/" . $file)) && $file != "." && $file != "..") { echo "文件名:", $file, "

    "; tree($dir . "/" . $file . "/"); } else { if ($file != "." && $file != "..") { echo $file . "
    "; } } } closedir($dh); } } }

     

    你可能感兴趣的:(PHP学习笔记)