温馨提示×

php中file_exists函数的用法是什么

PHP
小亿
82
2024-02-20 11:43:31
栏目: 编程语言

file_exists函数用于检查文件或目录是否存在。其语法如下:

bool file_exists ( string $filename )

参数$filename为要检查的文件或目录的路径。如果文件或目录存在,则返回true;否则返回false。下面是一个示例:

if (file_exists("myfile.txt")) {
    echo "文件存在";
} else {
    echo "文件不存在";
}

0