How to calculate the size of a file in php

青灯夜游
Release: 2023-03-11 15:50:02
Original
3513 people have browsed it

In PHP, you can use the filesize() function to calculate the size of a file, the syntax format is "filesize(filename)". The filesize() function can return the size of the specified file; if successful, it returns the number of bytes of the file size, if it fails, it returns FALSE.

How to calculate the size of a file in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In PHP, you can use filesize () function to calculate the size of a file.

filesize() function returns the size of the specified file.

Syntax

filesize(filename)
Copy after login
  • Parameter filename: specifies the file to be checked and cannot be omitted.

Return value: If successful, this function returns the number of bytes of the file size; if failed, it returns FALSE.

Example: Calculate and return the size of the test.txt file

Copy after login

Output:

20
Copy after login

Recommended learning:《PHP Video tutorial

The above is the detailed content of How to calculate the size of a file in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!