Loading... # [如何用 PHP 获取目录大小](https://blog.p2hp.com/archives/8741) ```php function GetDirectorySize($path){ $bytestotal = 0; $path = realpath($path); if($path!==false && $path!='' && file_exists($path)){ foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object){ $bytestotal += $object->getSize(); } } return $bytestotal; } ``` 最后修改:2023 年 08 月 12 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏