位置: 编程技术 - 正文
推荐整理分享PHP:clearstatcache()的用法_Filesystem函数,希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 4, PHP 5)
clearstatcache — 清除文件状态缓存
说明 void clearstatcache ([ bool $clear_realpath_cache = false [, string $filename ]] )当使用 stat(),lstat() 或者任何列在受影响函数表(见下面)中的函数时,PHP 将缓存这些函数的返回信息以提供更快的性能。然而在某些情况下,你可能想清除被缓存的信息。例如如果在一个脚本中多次检查同一个文件,而该文件在此脚本执行期间有被删除或修改的危险时,你需要清除文件状态缓存。这种情况下,可以用 clearstatcache() 函数来清除被 PHP 缓存的该文件信息。
必须注意的是,对于不存在的文件,PHP 并不会缓存其信息。所以如果调用 file_exists() 来检查不存在的文件,在该文件没有被创建之前,它都会返回 FALSE。如果该文件被创建了,就算以后被删除,它都会返回 TRUE 函数 unlink() 会自动清除该缓存.
Note:
本函数缓存特定文件名的信息,因此只在对同一个文件名进行多次操作并且需要该文件信息不被缓存时才需要调用 clearstatcache()。
受影响的函数包括 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()。
参数clear_realpath_cache
是否清除真实路径缓存
filename清除文件名指定的文件的真实路径缓存; 只在 clear_realpath_cache 为 TRUE 时启用
返回值没有返回值。
更新日志版本 说明 5.3.0 增加了可选的 clear_realpath_cache 和 filename 参数.
范例
Example #1 clearstatcache() 例子
<?php$file='output_log.txt';functionget_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($file,'ross');printf($format,date('r'),get_owner($file));clearstatcache();printf($format,date('r'),get_owner($file));?>以上例程的输出类似于:
PHP:chmod()的用法_Filesystem函数 chmod(PHP4,PHP5)chmod改变文件模式说明boolchmod(string$filename,int$mode)尝试将filename所指定文件的模式改成mode所给定的。参数filename文件的路径。mode注意mode不会
PHP:chown()的用法_Filesystem函数 chown(PHP4,PHP5)chown改变文件的所有者说明boolchown(string$filename,mixed$user)尝试将文件filename的所有者改成用户user(由用户名或用户ID指定)。只有超级用户可
PHP:basename()的用法_Filesystem函数 basename(PHP4,PHP5)basename返回路径中的文件名部分说明stringbasename(string$path[,string$suffix])给出一个包含有指向一个文件的全路径的字符串,本函数返回基本的
标签: PHP:clearstatcache()的用法_Filesystem函数
本文链接地址:https://www.jiuchutong.com/biancheng/285243.html 转载请保留说明!上一篇:PHP:disk_free_space()的用法_Filesystem函数
友情链接: 武汉网站建设