Home  >  Article  >  php教程  >  file_exists -检查文件或目录是否存在

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

WBOY
WBOYOriginal
2016-06-13 11:17:191370browse

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

file_exists
( PHP 4中, PHP 5中)

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

描述
布尔file_exists (字符串$文件名)
检查是否存在文件或目录。

参数

文件名
路径的文件或目录。

在Windows中,使用/ /计算机名/共享/文件名或 计算机名共享文件名,以检查网络共享上的文件。


返回值
返回TRUE ,如果指定的文件或目录的文件名存在; FALSE的除外。

注:此功能将返回FALSE的符号链接指向不存在的文件。


警告
此功能返回FALSE的文件,由于无法进入安全模式的限制。但这些文件还可以包含如果他们位于safe_mode_include_dir 。

注:检查是使用真正的UID / GID的不是有效的。


实例

例如# 1测试文件是否存在

$filename = '/path/to/foo.txt';

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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php get_meta_tags 函数Next article:php filesize 函数