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

/home/ privacy

Posted by Weedy, 04-14-2009, 09:19 AMHow do I keep users from spying on each others files? If I...

How to: secure yourself with (( cgitelnet.pl ))

Posted by X-x-X, 05-04-2007, 09:39 PMIt’s very important thing [URL removed] A hacker use...

Voxtreme...the best of the best?

Posted by Chaps, 07-22-2002, 06:10 PMYo peops... I have been torn between Voxtreme and MChost...

permissions

Posted by shakybaky, 06-26-2008, 04:24 AMI have a vps running centos5 WHM/cpanel I recently...

Whats the best for

Posted by zefefre, 01-14-2008, 12:40 AMsorry double thread . mod please delete this one....