PHP code calculation file Size development Example

Source: Internet
Author: User
In our previous article PHP download remote file storage to the local development example we introduced the use of PHP to download remote files and save to the local instance, then in our work, we often encounter a file calculation, PHP has to get the size of the file number of bytes of the function, but without units, This is not very convenient, today we will introduce how to achieve the calculation of file size with units of the example of the detailed!

The first step is to download the PHP code class library that we need to calculate the file size for this lesson: http://www.php.cn/xiazai/leiku/689

The second step, after the download, find the PHP class files we need, unzip to our local directory, create a new PHP file!

After the third step, we will call this class in the new PHP file, and instantiate the class:

<?phpinclude_once "codejisuan.php"; Introduce class file $dir_size=dirsize ("D:/phpstudy/www"); The name of the file size that needs to be computed echo round ($dir _size/pow (1024,1), 2). " KB "; Output?>

Run this file and get the results as shown:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.