Definition and usage
The function of clearstatcache() is to clear the file status cache.
PHP’s cached data is very beneficial for running functions faster and better. If a file is tested multiple times in a script, you might disable caching of correct results. To achieve this, you can use the clearstatcache() function.
Syntax
clearstatcache()
Tips and Notes
Tip: Functions that perform caching:
stat()
lstat()
file_exists()
is_writable()
is_readable()
is_executable()
is_file()
is_dir()
is_link()
filectime()
fileatime()
filemtime()
fileinode()
filegroup()
fileowner()
filesize()
filetype()
fileperms()
Case
Copy code The code is as follows:
//check filesize
echo filesize("test.txt");
echo "
";
$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 result:
792100
http://www.bkjia.com/PHPjc/321402.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321402.htmlTechArticleDefinition and usage The role of the clearstatcache() function is to clear the file status cache. PHP's cached data is very beneficial for running functions faster and better. If a file is tested in a script...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn