PHP obtains the folder size function usage instance ,. Example of PHP function usage for getting the folder size. this example describes how to use PHP function for getting the folder size. Share it with you for your reference. Details: php getting folder size PHP getting folder size function usage instance,
This example describes how to use PHP to obtain the folder size function. Share it with you for your reference. The details are as follows:
<? Php // Get the 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 ;} // function getRealSize ($ size) {$ kb = 1024; // Kilobyte $ mb = 1024 * $ kb; // Megabyte $ gb = 1024 * $ mb; // Gigabyte $ tb = 1024 * $ 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 ('directory to be retrieved size');?>
I hope this article will help you with php programming.
Example: This article describes how to use PHP to obtain the folder size function. Share it with you for your reference. Php // Get the folder size...