file_exists() 函数用于检查一个文件或目录是否存在。
file_exists() 函数检查文件或目录是否存在,成功返回 TRUE,否则返回 FALSE 。
语法:
bool file_exists( string filename )
例子:
<?php
$filename = 'test.txt';
if (file_exists($filename)) {
echo "文件 $filename 存在";
} else {
echo "文件 $filename 不存在";
}
?>