Re: clearstatcache, how to use?
| From: | Greg Beaver | Date: | Mon, 25 Oct 2004 07:01:13 +0000 |
| Subject: | Re: clearstatcache, how to use? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200218@lists.php.net to get a copy of this message | ||
Louie Miranda wrote:
I have this code that checks for a file if it exists and do something if it doesnt exist. Problem exist when im updating my data on the directory, even if i did upload it. it still shows the non-existent data. I have read that i should add the clearstatcache();, how am i going to use it? after the file_exists? or before? here's my code ## $itemCode_SHOW = $row[2]; $filename =("/www/images/stockprod/$itemCode_SHOW.jpg"); if (file_exists($filename)) {clearstatcache() is very descriptive for php, actually :). Most filesystem functions make use of statistics about a file. Gathering this information is expensive, so it is cached. If something changes, you have to clear the cache to see the change, so: clearstatcache(); if (file_exists($filename)) { is what you need if (file_exists($filename)) { ... } clearstatcache(); will have no impact on the problem, because you are clearing the cache *after* the function that relies on the cache has been called. Greg$itemCode_SHOW = $row[2];} else {$itemCode_SHOW = "noimage";} clearstatcache(); ##