I know there quite a bit of in-built functions available in PHP to get size of the file, some of them are: filesize, stat, ftell, etc.
My question lies around ftell which is quite interesting, it returns you the integer value of the file-pointer from the file.
Is it possible to get the size of the file using ftell function? If yes, then tell me how?
Scenario:
- System (code) opens a existing file with mode "a" to append the contents.
- File pointer points to the end of line.
- System updates the content into the file.
- System uses
ftellto calculate the size of the file.
fstatdetermines the file size without any acrobatics:ftellcan not be used when the file has been opened with the append("a") flag. Also, you have to seek to the end of the file withfseek($f, 0, SEEK_END)first.