Home>Article>Backend Development> Detailed explanation of the use of php clearstatcache() function
clearstatcache() function clears the file status cache.
PHP will cache the return information of some functions to provide higher performance. But sometimes, such as when you check the same file multiple times in a script and the file is in danger of being deleted or modified during the execution of the script, you need to clear the file status cache in order to get the correct results. To do this, use the clearstatcache() function.
Syntax
clearstatcache()
Tips: Functions that perform caching, that is, functions affected by the clearstatcache() function:
stat()
lstat()
is_writable( )
is_readable()
filectime()
##filetype()
"; $file = fopen("test.txt", "a+"); // truncate file ftruncate($file,100); fclose($file);//Clear cache and check filesize againcle arstatcache(); echo filesize("test.txt"); ?>The above code will output the following results:
792100
The above is the detailed content of Detailed explanation of the use of php clearstatcache() function. For more information, please follow other related articles on the PHP Chinese website!