SplFileInfo::getSize

(PHP 5 >= 5.1.2)

SplFileInfo::getSizeGets file size

Description

public int SplFileInfo::getSize ( void )

Returns the filesize in bytes for the file referenced.

Parameters

This function has no parameters.

Return Values

The filesize in bytes.

Errors/Exceptions

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

See Also

Коментарии

Seems to return FALSE if file does not exists... (PHP 5.3.4)
2011-04-30 08:59:22
http://php5.kiev.ua/manual/ru/splfileinfo.getsize.html
Автор:
Check function.filesize#115792 for fast and reliable version of filesize for files >2gb on 32 bit systems.
2016-03-14 22:21:24
http://php5.kiev.ua/manual/ru/splfileinfo.getsize.html
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 :|
2018-05-30 11:38:41
http://php5.kiev.ua/manual/ru/splfileinfo.getsize.html
Автор:
When getSize return 0, after fwrtite, You must use clearstatcache:

$tmpFile = new \SplFileObject('/tmp/file.txt');
$fp = $tmpFile->openFile('w');
$fp->fwrite('123');
$fp->fflush();
echo $fp->getSize(); //Return 0
clearstatcache();
echo $fp->getSize(); //Return 3

https://bugs.php.net/bug.php?id=72182
2023-05-11 11:41:36
http://php5.kiev.ua/manual/ru/splfileinfo.getsize.html

    Поддержать сайт на родительском проекте КГБ