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.

Was this answer helpful?

 Print this Article

Also Read

Adult Hosting

Posted by Nell, 09-03-2002, 02:07 AMI search resellers hosting plan for adult sites. The main...

How can I get the memory offsets that functions in a dll access?

Posted by lJesterl, 02-11-2011, 11:57 PMI am developing an anti cheat patch for a friend for an...

Sortable Table

Posted by AvailNetworks, 03-02-2010, 10:42 PMsorry if I sound like a moron when it comes to...

SNMP Monitoring

Posted by g3tech, 08-27-2003, 10:23 PMHello, Was just wondering what you guys out there use to...

Elgg - Group Discussions

Posted by jamiedolan, 02-12-2011, 07:20 PMHello; I found a free application called Elgg. It's...