PHP is_dir() 函數


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

定義和用法

is_dir() 函數檢查指定的檔是否是一個目錄。

如果目錄存在,該函數返回 TRUE。

語法

is_dir(file)

參數 描述
file 必需。規定要檢查的檔。


提示和注釋

注釋:該函數的結果會被緩存。請使用 clearstatcache() 來清除緩存。


實例

<?php
$file = "images";
if(is_dir($file))
{
echo ("$file is a directory");
}
else
{
echo ("$file is not a directory");
}
?>

上面的代碼將輸出:

images is a directory


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