Home > Backend Development > PHP Tutorial > Detailed explanation of PHP clearstatcache() function_PHP tutorial

Detailed explanation of PHP clearstatcache() function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:40:15
Original
991 people have browsed it

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

www.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 of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template