共計 371 個字符,預計需要花費 1 分鐘才能閱讀完成。
file_exists 函數是一個 PHP 內置函數,用于檢查文件或目錄是否存在。
語法:
bool file_exists (string $filename)
參數:
- $filename:要檢查的文件或目錄的路徑。
返回值:
如果文件或目錄存在,則返回 true,否則返回 false。
示例:
$filename = '/path/to/file.txt';
if (file_exists($filename)) {echo " 文件存在 ";
} else {echo " 文件不存在 ";
}
注意事項:
- file_exists 函數對于目錄和文件都適用。
- 如果要檢查遠程文件是否存在,可以使用 file_exists 函數配合 URL。
- file_exists 函數可以檢查文件和目錄的可讀性權限。
- file_exists 函數返回布爾值,可以用于條件判斷。
丸趣 TV 網 – 提供最優質的資源集合!
正文完