For php clearstatcache-Clear the File status cache, we will explain it one by one. There are also specific instances.
About phpClearstatcache-Clear the File status cache. Here are some examples.
Clearstatcache
(PHP 4 and PHP 5)
Clearstatcache-Clear the File status Cache
Description
Invalid clearstatcache ([Boolean $ clear_realpath_cache = false [, string $ file name])
When you use statistics (), lstat (), or a list of affected functions listed in any other function (as shown below), PHP Cache Information resumes these functions, to provide faster performance. However, in some cases, you may need to clear the cache information. For example, if the same file is being checked multiple times in a script, the file is dangerous to delete or change in the script running, you can choose to clear the cache status. In this case, you can use the clear information of the clearstatcache () function to cache related files in PHP.
You should also note that PHP does not cache files whose information does not exist. Therefore, if you require that the file on file_exists () does not exist, it returns FALSE until you create the file. If you create a file, it returns even if you then delete the file. However, disconnecting () automatically clears the cache.
Note: This function caches the specific file names of information, so you only need to call clearstatcache (). If you are engaged in multiple businesses with the same file name, you must not cache the specific file.
Affected functions include statistics (), lstat (), file_exists (), is_writable (), is_readable (), is_executable (), is_file (), is_dir (), is_link (), filectime (), fileatime (), filemtime (), fileinode (), filegroup (), fileowner (), file size (), file type (), and fileperms ().
Parameters
Clear_realpath_cache
Each time the cache is cleared or no realpath is cleared (the default value is false ).
File Name
Specify the specific file name of the realpath cache. If you only use clear_realpath_cache, it is true.
Return Value
Returns without value.
Modify
Version description
The clear_realpath_cache and file name parameters are optional in 5.3.0.
Instance
Example #1 clearstatcache ()
$ File = 'output_log.txt ';
Function get_owner ($ file)
{
$ Stat = stat ($ file );
$ User = posix_getpwuid ($ stat ['uid']);
Return $ user ['name'];
}
$ Format = "UID @ % s: % sn ";
Printf ($ format, date ('R'), get_owner ($ file ));
Chown ($ path, 'ross ');
Printf ($ format, date ('R'), get_owner ($ file ));
Clearstatcache ();
Printf ($ format, date ('R'), get_owner ($ file ));
?>
Output
UID @ Sun, 12 Oct 2008 20:48:28 + 0100: root
UID @ Sun, 12 Oct 2008 20:48:28 + 0100: root
UID @ Sun, 12 Oct 2008 20:48:28 + 0100: ross