SplFileInfo::getSize
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.1.2, PHP 7, PHP 8)
Gets file size
Description
SplFileInfo::getSize(): int|false
Returns the filesize in bytes for the file referenced.
Parameters Parameters
Return Values
The filesize in bytes on success, or false on failure.
Errors/Exceptions
A RuntimeException will be thrown if the file does not exist or an error occurs.
Examples
SplFileInfo::getSize example
php
<?php
$info = new SplFileInfo('example.jpg');
echo $info->getFilename() . " " . $info->getSize();
?>The above example will output something similar to:
output
example.jpg 15385