The function of the size of the PHP statistics directory file

time:17-03-20 forum:PHP tools and code
  http://www.jb51.net/article/76951.htm

this function can recursively traverse all files in the directory and calculate the total file size in MB.
[code]
.lt;? Php
recycle all the files in the directory, and the size of the directory and file size
$dirName=.quot; phpMyAdmin.quot;
$dir=opendir ($dirName); returns a resource type
while. EName! =.quot;..quot;.Amp;.Amp; $fileName! =.quot; quot;) {
if. Br/.gt;.Quot;
}
else{
echo.Quot;.Lt; font color='green'.gt;.Quot;.$fileName..Quot. }
closedir ($dir);

convert the size of a file or directory into a easy to read way
function toSize ($size) {
$dw; Ize.gt; pow (2,20)) {
$dw=.quot; MB.quot;
$size=round ($size/pow (2,20), 2);
}
>; R / > function dirSize ($dirName) {
$dirsize=0;
$dir=opendir ($dirName);
while / > {/ / 1]
if (is_dir ($file)) {
$dirsize =dirSize ($file);
}
$dirsize / > >;

prev:The number of specified extension files ... next:The difference and meaning of PHP regula...
post comment
Notice



approved   Query the operation system informati...   Phoenix reporter Dunfee and others l...   BigDog big foot transport robot in t...   Go to Ji'nan Lantau Peak set (standa...   Reminder: handle the delivery proced...
rand   PHP regular expression summary   PHP probability operation function   PHP video tutorials LAMP brothers, o...   Regular regular expressions   PHP code shields China's IP address
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com