用PHP来计算某个目录大小的方法
更新时间:2014年04月01日 17:46:50 作者:
这篇文章主要介绍了用PHP来计算某个目录大小的方法,需要的朋友可以参考下
PHP CURL session COOKIE
可以调用系统命令,还可以这样:
function dirsize($dir) {
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir."/".$file;
if (is_dir($path)) {
$size += dirsize($path);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
return $size;
}
$bb = "/var/www/lg";
$cc = dirsize("$bb");
$aa = $cc/1024/1024;
echo $aa.MB."
"."
";
可以调用系统命令,还可以这样:
复制代码 代码如下:
function dirsize($dir) {
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir."/".$file;
if (is_dir($path)) {
$size += dirsize($path);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
return $size;
}
$bb = "/var/www/lg";
$cc = dirsize("$bb");
$aa = $cc/1024/1024;
echo $aa.MB."
"."
";
相关文章
php使用Image Magick将PDF文件转换为JPG文件的方法
这篇文章主要介绍了php使用Image Magick将PDF文件转换为JPG文件的方法,涉及php使用Image Magick扩展操作图片的技巧,具有一定参考借鉴价值,需要的朋友可以参考下2015-04-04php出现Cannot modify header information问题的解决方法大全
我做了一个统一的出错提示函数,在函数执行里面,先处理出错的地址写入cookie以方便用户登陆以后可以直接跳转到要执行的这个页面,可是发现在服务器上测试时,竟然提示本地没有出现的错误: Warning: Cannot modify header information - headers already sent by....2008-04-04
最新评论