PHP file_exists()函数 file_exists()函数可以检查文件或目录是否存在。如果文件或目录存在,该函数返回true,否则返回false。 语法 bool file_exists ( string $filename )PHPCopy 这个函数可以检查文件或目录是否存在。 示例 <?php filename = "/PhpProject/sample.txt"; if(file_exists(filename)) { echo "The file filename exists"; } else { echo "The filefilenamedoes not exist"; } ?>PHPCopy 输出 The file /PhpProject/sample.txt existsPHPCopy