php 遍历文件夹及其子目录

function getfiles($path) {
        $handle = opendir($path);
        while(($file=readdir($handle)) !==false) {
            if($file !='.' && $file !='..') {
                $path2= $path.'/'.$file;
                if(is_dir($path2)) {
                    echo $file;
                    echo "<br/>";
                    getfiles($path2);
                }else {
                    echo $file;
                    echo "<br/>";
                }
            }
        }
    }
面试可能需要,备之

你可能感兴趣的:(PHP,遍历文件夹及其子目录)