php8.5
Home/ Manual/ filesystem / functions/ filesize

filesize

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Gets file size

Description

filesize(string $filename): int|false

Gets the size for the given file.

Parameters

filename

Path to the file.

Return Values

Returns the size of the file in bytes, or false (and generates an error of level E_WARNING) in case of an error.

32bit

Errors/Exceptions Failure

Examples

filesize() example

php
<?php

// outputs e.g.  somefile.txt: 1024 bytes

$filename = 'somefile.txt';
echo $filename . ': ' . filesize($filename) . ' bytes';

?>

Notes Clearstatcache Stat

See Also

Source: reference/filesystem/functions/filesize.xml · from the official PHP manual (php/doc-en)