search
HomeBackend DevelopmentPHP ProblemHow to calculate the size of a file in php

How to calculate the size of a file in php

Jul 15, 2021 pm 07:36 PM
phpFile size

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)
  • 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

<?php
echo filesize("test.txt");
?>

Output:

20

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment