Latest web development tutorials

PHP is_readable() 函數

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

定義和用法

is_readable() 函數檢查指定的文件是否可讀。

如果文件可讀,該函數返回TRUE。

語法

is_readable(file)

参数 描述
file 必需。规定要检查的文件。


提示和註釋

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


實例

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

上面的代碼將輸出:

test.txt is readable


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