PHP is_writable() 函式
❮ PHP 檔案系統參考示例
檢查指定的檔名是否可寫
<?php
$file = "test.txt";
if(is_writable($file)) {
echo ("$file is writable");
} else {
echo ("$file is not writable");
}
?>
上面程式碼的輸出可能是
test.txt is writable
定義和用法
is_writable() 函式用於檢查指定的檔名是否可寫。
注意: 此函式的結果會被快取。使用 clearstatcache() 來清除快取。
語法
is_writable(file)
引數值
引數 | 描述 |
---|---|
file | 必需。指定要檢查的檔案的路徑 |
技術詳情
返回值 | 如果檔案可寫,則返回 TRUE,否則返回 E_WARNING。 |
---|---|
PHP 版本 | 4.0+ |
❮ PHP 檔案系統參考