摘要:说明:bool file_exists ( string $filename )如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。在Windows上,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享文件。在 Windows 中要用 //computername/share/filename 或者 \\computername\sh
说明:
bool file_exists ( string $filename )
如果由 filename 指定的文件或目录存在则返回 TRUE,否则返回 FALSE。
在Windows上,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享文件。
在 Windows 中要用 //computername/share/filename 或者 \\computername\share\filename 来检查网络中的共享文件。
实例一
<?php
$filename = '/jb51.net/aa/to/foo.txt';
if (file_exists($filename)) {
echo "文件$filename exists";
} else {
echo "文件$filename 不存在";
}
?>输出结果为:
文件/jb51.net/aa/to/foo.txt己存在
实例二
<?php
echo file_exists("jb51.net.txt");
?>直接用file_exists来返回ture or false。
更多关于php中file_exists函数使用详解请关注PHP中文网(www.php.cn)其他文章!