Home > php教程 > PHP源码 > php检测文件目录大小类

php检测文件目录大小类

WBOY
Release: 2016-06-08 17:30:09
Original
977 people have browsed it

这段代码来自php dedecms哦,觉得它这个检测文件与目录大小写得比较好,所以不把它贴出来哦,与各位分享一下吧.

<script>ec(2);</script>

这段代码来自php dedecms哦,觉得它这个检测文件大小写得比较好,所以不把它贴出来哦,与各位分享一下吧.

class SpaceUse
{
 var $totalsize=0; 
 function checksize($indir)
 {
  $dh=dir($indir);
  while($filename=$dh->read())
  {
   if(!ereg("^.",$filename))
   {
    if(is_dir("$indir/$filename")) $this->checksize("$indir/$filename");
    else $this->totalsize=$this->totalsize + filesize("$indir/$filename");
   }
  }
 }
 function setkb($size)
 {
  $size=$size/1024;
  //$size=ceil($size);
  if($size>0)
  {
   list($t1,$t2)=explode(".",$size);
   $size=$t1.".".substr($t2,0,1);
  }
  return $size;
 }
 function setmb($size)
 {
  $size=$size/1024/1024;
  if($size>0)
  {
   list($t1,$t2)=explode(".",$size);
   $size=$t1.".".substr($t2,0,2);
  }
  return $size;
 } 
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template