标签:style blog io color os sp on div log
<?php function dirSize($dir){ $dirSize = 0; if($dh = @opendir($dir)){ //@在函数前面屏蔽出现的错误 while(($filename = readdir ($dh))){ if($filename != "." && $filename != ".."){ //‘.‘当前目录,‘..‘父目录 if(is_file($dir."/".$filename)) $dirSize += filesize($dir."/"/$filename); if(is_dir($dir."/".$filename)) $dirSize += dirSize($dir."/".$filename); } } } @closedir($dh); return $dirSize; } $dir = ‘/......../‘; $totalSize = round((dirSize($dir) / 1048576), 2); //返回的数量是兆字节,1048576 等于 1MB
printf("directory %s: %f MB", $dir: $totalSize); ?>
标签:style blog io color os sp on div log
原文地址:http://www.cnblogs.com/lcpholdon/p/4150809.html