php遍历统计文件目录和文件

function total($dirname, &$dirnum, &$filenum){
        $dir=opendir($dirname);
        readdir($dir)."<br>";
        readdir($dir)."<br>";
        while($filename=readdir($dir)){
           $newfile=$dirname."/".$filename;

           if(is_dir($newfile)){
             total($newfile, $dirnum, $filenum);  
                 $dirnum++;
            }else{
                 $filenum++;
            }
        }
       closedir($dir);     
    }

   $dirnum=0;
   $filenum=0;
   total("C:/AppServ/www/phpMyAdmin", $dirnum, $filenum);

   echo "目录总数:".$dirnum."<br>";
   echo "文件总数:".$filenum."<br>";
If the copyright belongs to the longfei, please indicate the source!!!
原文地址:https://www.cnblogs.com/longfeiPHP/p/4688640.html