Clearstatcache in PHP
Last Update:2018-12-03
Source: Internet
Author: User
The clearstatcache () function is used to clear the File status cache.
PHP cache data is very advantageous for faster and better function running. If a file is tested in a script
After multiple attempts, you may not cache the correct results. To achieve this, you can use
Clearstatcache () function.
When Stat (), lstat (), or any function column in the affected function table (see the following figure) is used,
PHP will cache the returned information of these functions to provide faster performance. However, in some cases, you may
To clear the cached information. For example, if the same file is checked multiple times in a script
When this script is executed, you need to clear the File status cache when it is deleted or modified. This situation
You can use the clearstatcache () function to clear the file information cached by PHP.
Note that PHP does not cache the information of non-existing files. So if you call
File_exists () to check for non-existing files. Before the file is created, it will return
False. If the file is created, true is returned even if it is deleted later.
Note: This function caches the information of a specific file name. Therefore, it only performs operations on the same file name multiple times and
Clearstatcache () is called only when the file information is not cached ().
Syntax
Clearstatcache ()
Tips and notes
Tip: Execute the cache function:
Stat ()
Lstat ()
File_exists ()
Is_writable ()
Is_readable ()
Is_executable ()
Is_file ()
Is_dir ()
Is_link ()
Filectime ()
Fileatime ()
Filemtime ()
Http://www.ibwen.com love blog provides massive data to meet your thirst for knowledge!
All resources on this site are reprinted from the internet! Copyright owned by the author
Http://www.ibwen.com
Fileinode ()
Filegroup ()
Fileowner ()
Filesize ()
Filetype ()
Fileperms ()
Case
<? PHP
// Check filesize
Echo filesize ("test.txt ");
Echo "<br/> ";
$ 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:
792
100