file_exists
时间:2007-05-26 来源:Wing.J
file_exists -- 检查文件或目录是否存在
说明
bool file_exists ( string filename)
如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。
例子 1. 测试一个文件是否存在
[color="#0000bb"][color="#007700"];
if ([color="#0000bb"]file_exists[color="#007700"]([color="#0000bb"]$filename[color="#007700"])) {
print [color="#dd0000"]"The file $filename exists"[color="#007700"];
} else {
print [color="#dd0000"]"The file $filename does not exist"[color="#007700"];
}
[color="#0000bb"]?>
注: 本函数的结果会被缓存。详细信息参见
clearstatcache()
。
注: 本函数不能作用于
远程文件
,被检查的文件必须通过服务器的文件系统访问。
相关阅读 更多 +
排行榜 更多 +