How does PHP fstat() function work?
Does the function read file size from disk on every call?
Or does the function calculate the size based on all writing operations performed?
Example:
$filename='abc.txt';
$fp=fopen($filename, 'a');
$fstat=fstat($fp);
echo 'Size: '.$fstat['size'].'<br><br>';
echo 'Writing...<br><br>';
fwrite($fp, 'xx');
fwrite($fp, 'yyyy');
// ...
// Some number of fwrite() opertions
// ...
fwrite($fp, 'zzzzzz');
$fstat=fstat($fp);
echo 'Size after writing: '.$fstat['size'].'<br>';
// Does the size is read from disk or is calculated based on earlier writing operations?
fclose($fp);