/**
* 获取目录大小
*
* @param string $path 目录
* @param int $size 目录大小
* @return int 整型类型的返回结果
*/
function getDirSize($path, $size = 0)
{
$dir = @dir($path);
if (!empty($dir->path) && !empty($dir->handle)) {
while ($filename = $dir->read()) {
if ($filename != '.' && $filename != '..') {
if (is_dir($path . DS . $filename)) {
$size += getDirSize($path . DS . $filename);
} else {
$size += filesize($path . DS . $filename);
}
}
}
}
return $size ? $size : 0;
}