PHP file_exists() 函數


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊

定義和用法

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

如果指定的檔或目錄存在則返回 TRUE,否則返回 FALSE。

語法

file_exists(path)

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


實例

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

上面的代碼將輸出:

1


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊