php[world] 2019 — 25 years of PHP

SplFileInfo::getSize

(PHP 5 >= 5.1.2, PHP 7)

SplFileInfo::getSizeПолучает размер файла

Описание

public SplFileInfo::getSize ( void ) : int

Возвращает размер файла в байтах.

Список параметров

У этой функции нет параметров.

Возвращаемые значения

Размер файла в байтах.

Ошибки

Будет выброшено исключение RuntimeException, если файл не существует или возникла ошибка.

Смотрите также

  • filesize() - Возвращает размер файла

add a note add a note

User Contributed Notes 4 notes

up
2
franssen dot roland at gmail dot com
8 years ago
Seems to return FALSE if file does not exists... (PHP 5.3.4)
up
0
random-citizen at example dot org
1 year ago
If you're using Symfony's UploadedFile, 
please be aware that if you call this method 
_after_ you call @move, you will most likely get 
some obscenely untraceable error, that says:

`stat failed`

Which if you really think about it, it does makes sense, 
the file has been moved by Symfony, but getSize is in SplFileInfo, 
and SplFileInfo doesn't know that the file has been moved.

Weirdly enough, that error doesn't come on my work mac :|
up
0
Anonymous
3 years ago
Check http://php.net/manual/en/function.filesize.php#115792 for fast and reliable version of filesize for files >2gb on 32 bit systems.
up
-1
contact at socialdevelop dot biz
3 years ago
if use it as SplFileInfo::getSize - it return false if file not found
if use it as SplFileObject::getSize - it generate RuntimeException: SplFileObject::__construct(my-file): failed to open stream: No such file or directory
To Top