PHP file_exists() 函數

定義和用法

file_exists() 函數檢查文件或目錄是否存在。

如果指定的文件或目錄存在則返回 true,否則返回 false。

語法

file_exists(path)
參數 描述
path 必需。規定要檢查的路徑。

實例

<?php
echo file_exists("test.txt");
?>

輸出:

1