PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<fgetssfile_get_contents>
Last updated: Mon, 16 Jul 2012

file_exists

(PHP 3, PHP 4, PHP 5)

file_exists -- 检查文件或目录是否存在

说明

bool file_exists ( string filename )

如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE

在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。

例子 1. 测试一个文件是否存在

<?php
$filename
= '/path/to/foo.txt';

if (
file_exists($filename)) {
   print
"The file $filename exists";
} else {
   print
"The file $filename does not exist";
}
?>

注: 本函数的结果会被缓存。详细信息参见 clearstatcache()

注: 本函数不能作用于远程文件,被检查的文件必须通过服务器的文件系统访问。

参见 is_readable()is_writable()is_file()file()




<fgetssfile_get_contents>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST