0

I am testing out the PHP clearstatchache function as follows:

//[1] First attempt to access non-existent file
 var_dump(file_exists("gates.txt"));

returns false

//[2] Now manually create the file in the directory.
//[3] Run the script again.

It returns true.

//[4] manually delete the file
//[5] run script once again

returns false

Now from my understanding of the following line from the http://www.php.net/manual/en/function.clearstatcache.php

"You should also note that PHP doesn't cache information about non-existent files. So, if you call file_exists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file."

The function should return true after I manually delete the file.

Any explanations would help!

1 Answer 1

2

The cache is just per script run.

Sign up to request clarification or add additional context in comments.

3 Comments

So how would I get it to display true after manually deleting the file?
I've tried to reproduce the behaviour described in the manual with this code: pastebin.com/VSMVWqS0 . I couldn't reproduce the behaviour described in the PHP manual
Note: Couldn't reproduce means not that I didn't saw this behaviour several times while debugging scripts. But it seems hard to reproduce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.