note 124251 added to function.filesize
| From: | JohnCrocker@php.net | Date: | Mon, 30 Sep 2019 12:46:24 +0000 |
| Subject: | note 124251 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212440@lists.php.net to get a copy of this message | ||
The first example given may lead one to assume that this function works with a local filename e.g.
$fs = filesize("error_log") but if you manually delete some text, then save and close the
file, the next time you check filesize("error_log") it will return the original value,
because the value is cached for performance reasons. If you didn't know this, it would look
like a nasty bug.
So, everyone tells you to insert clearstatcache() which is supposed to clear the cached value and
allow you to retrieve the current file size but it still does nothing and looks like another bug!
However, I found that if you always specify the FULL PATH
e.g. $fs = filesize("/user/some/path/error_log");
then clearstatcache() is not even needed.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 88.97.13.167)
----
Manual Page -- http://php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/124251
Del: integrated -- https://master.php.net/note/delete/124251/integrated
Del: useless -- https://master.php.net/note/delete/124251/useless
Del: bad code -- https://master.php.net/note/delete/124251/bad+code
Del: spam -- https://master.php.net/note/delete/124251/spam
Del: non-english -- https://master.php.net/note/delete/124251/non-english
Del: in docs -- https://master.php.net/note/delete/124251/in+docs
Del: other reasons-- https://master.php.net/note/delete/124251
Reject -- https://master.php.net/note/reject/124251
Search -- https://master.php.net/manage/user-notes.php