Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<SplFileInfo::getRealPathSplFileInfo::getType>
^SplFileInfoLast updated: Mon, 26 Oct 2026

SplFileInfo::getSize

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplFileInfo::getSize — Gets file size

Description

public function SplFileInfo::getSize(): int|false

Returns the filesize in bytes for the file referenced.

Parameters

This function has no 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

Example #1 SplFileInfo::getSize() example

<?php
$info = new SplFileInfo('example.jpg');
echo $info->getFilename() . " " . $info->getSize();
?>

The above example will output something similar to:

example.jpg 15385

See Also


<SplFileInfo::getRealPathSplFileInfo::getType>
^SplFileInfoLast updated: Mon, 26 Oct 2026