PHP is_writable() 函數


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

定義和用法

is_writable() 函數檢查指定的檔是否可寫。

如果檔可寫,該函數返回 TRUE。

語法

is_writable(file)

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


提示和注釋

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


實例

<?php
$file = "test.txt";
if(is_writable($file))
{
echo ("$file is writeable");
}
else
{
echo ("$file is not writeable");
}
?>

上面的代碼將輸出:

test.txt is writeable


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