SplFileInfo::getSize
PHP Manual
PHP Manual»SplFileInfo»SplFileInfo::getSize

SplFileInfo::getSize

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

SplFileInfo::getSizeGets file size

Опис

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

Returns the filesize in bytes for the file referenced.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

The filesize in bytes on success, or false on failure.

Помилки/виключення

A RuntimeException will be thrown if the file does not exist or an error occurs.

Приклади

Приклад #1 SplFileInfo::getSize() example

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

Поданий вище приклад виведе щось схоже на:

example.jpg 15385

Прогляньте також

To Top