clearstatcache - Third time lucky... (PHP question)
Posted by thomase, 09-11-2008, 02:21 PM I've asked two people who are pretty good at PHP and no luck so far. I've got this bit of code which needs to check if a file exists before echoing the file. Now, according to php.net file_exists caches on the server so you've got to use clearstatcache everytime to remove this cache to check again. I've tried it without the varible in, with it in, above the thing, below, etc, and still have had no luck getting it to work! The url is correct too...and a file exists but it still doesn't echo anything. Any help is appreciated
Posted by Adam-AEC, 09-11-2008, 02:34 PM Single quotes escape variables! Remove them when you are just specifying the variable between the quotes, and use double quotes in the variable assignment. And you shouldn't have to worry about clearing the cache unless you are checking the existence of that file twice in one request.
Posted by thomase, 09-11-2008, 02:55 PM That's not worked. The image path is still correct when I echo it, but it's not finding the file (with or without the clearstatscache)
Posted by Adam-AEC, 09-11-2008, 03:48 PM There are still single quotes around the variable where you call file_exists. So, it's looking for a file _actually_ called $filename. You don't want that. It should be: file_exists($filename)
Posted by thomase, 09-11-2008, 04:34 PM Thank you very much That's works! Last edited by sirius; 09-11-2008 at 04:38 PM.