clearstatcache
Clear file status cache
clearstatcache()
function clears the file state cache.
The clearstatcache()
function caches the return information of certain functions to provide higher performance. But sometimes, for example, if you check the same file multiple times in a script, and the file is in danger of being deleted or modified during execution of this script, you need to clear the file status cache to get the correct results. To do this, you need to use the clearstatcache() function.
A function that will be cached, that is, a function that is affected by clearstatcache()
function:
<?php //Check file size echo filesize ( "test.txt" ) ; $file = fopen ( "test.txt" , "a+" ) ; // Intercept the file ftruncate ( $file , 100 ) ; fclose ( $file ) ; //Clear cache and check file size again clearstatcache ( ) ; echo filesize ( "test.txt" ) ; ?>
Output:
792 100
clearstatcache ( )