So in our daily development work, I believe that many friends have encountered how to calculate the information of a specified folder. Everyone should be familiar with this. Calculate the size of a folder, including subfolders. Formatted output folder size, number of files, number of subfolders information. Today I will introduce to you the implementation process of PHP's information function for calculating the specified folder!
Similarly, we still need to download the PHP function library used in this course to calculate the information of the specified folder:
http:/ /m.sbmmt.com/xiazai/leiku/792
After the download is completed, unzip the php file library we need to the local directory, and then create a new php file~
Then we need to call this class and instantiate this class in this new php file:
<?php include_once "codehanshu.php"; //引入类文件 $path="../cache"; //定义指定文件夹路径 $ar=getDirectorySize($path); //实例化 //输出结果 echo "<h4>路径 : $path</h4>"; echo "目录大小 : ".sizeFormat($ar['size'])."<br>"; echo "文件数 : ".$ar['count']."<br>"; echo "目录术 : ".$ar['dircount']."<br>"; ?>
Run the above code, and the result will be as shown below:
The above is the detailed content of Implementation process of PHP calculating information function of specified folder. For more information, please follow other related articles on the PHP Chinese website!