PHP Check File Exists: file_exists Guide
In PHP, the function file_exists() can be used to check if a file exists. This function takes a file path as an argument and returns a boolean value indicating whether the file exists.示例如下:
$filename = "example.txt";
if (file_exists($filename)) {
echo "文件存在";
} else {
echo "文件不存在";
}