The first question to ask is, can is_file really replace file_exists? The answer is in the negative. Why? The reason is simple, is_file has a cache
We can use the following code to test: The code is as follows: <?php $filename = ' test.txt '; if (Is_file ($filename)) { echo "$filename exists!n"; } else { echo "$filename no exists!n"; } &NB Sp Sleep (10); if (Is_file ($filename)) { echo "$filename exists!n"; } else { echo "$filename no exists!n"; }?> when we run the test code, we do Paul Test.txt file exists. In the code above, the first time you use the Is_file function to determine if a file exists, and then call the sleep function for 10 seconds. In this 10 seconds, we will remove the Test.txt file. Finally look at the result of the second call to the Is_file function. The output results are as follows: Test.txt exists! Test.txt exists! Well, you are not wrong, two are output "Test.txt exists!", this is why? The reason is that Is_file has a cache. The first time that you call the Is_file function, PHP saves the file's properties (STAT), and when you call Is_file again, if the filename is the same as the first time, the cache is returned directly. What about changing is_file to file_exists? We can change the Is_file function of the above code to the File_exists function and use the test method above to test again. The results are as follows: Test.txt exists! Test.txt No exists! Second call FIle_exists when the return file does not exist, this is because the file_exists function is not cached, no time to call File_exists will go to the disk search file exists, so the second will return false. Said so much, I just want to explain is_file can not replace file_exists use, if you just feel is_file performance is good, then I have no way