PHP Gets a folder size function usage instance,
The example in this article describes how PHP gets the folder size function usage. Share to everyone for your reference. Specific as follows:
<?php//Get folder size function Getdirsize ($dir) { $handle = Opendir ($dir); while (false!== ($FolderOrFile = Readdir ($handle))) { if ($FolderOrFile! = "." && $FolderOrFile! = "...") { if (Is_dir ("$dir/$FolderOrFile")) { $sizeResult + = getdirsize ("$dir/$FolderOrFile"); } else { $sizeResult + = filesize ("$dir/$FolderOrFile") ; }}} Closedir ($handle); return $sizeResult; }//Unit auto CONVERT function getrealsize ($size) { $kb = 1024x768; Kilobyte $MB = 1024x768 * $KB;//megabyte $GB = 1024x768 * $MB;//Gigabyte $TB = 1024x768 * $GB;//Terabyte if ($size < $kb) { return $size. " B "; } else if ($size < $MB) { return round ($size/$KB, 2). " KB "; } else if ($size < $GB) { return round ($size/$MB, 2). " MB "; } else if ($size < $TB) { return round ($size/$GB, 2). " GB "; } else { return round ($size/$TB, 2). " TB "; } } Echo getrealsize (Getdirsize (' need to get the size of the directory '));? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1024904.html www.bkjia.com true http://www.bkjia.com/PHPjc/1024904.html techarticle PHP Gets the folder size function usage instance, this article describes the PHP Get folder size function usage. Share to everyone for your reference. The following: PHP//Get folder size ...