is_readable

(PHP 3, PHP 4, PHP 5)

is_readable -- 判斷給定檔案名是否可讀

說明

bool is_readable ( string filename )

若果由 filename 特殊的檔案或目錄存在並且可讀則返回 TRUE

記住 PHP 也許只能以運行 webserver 的會員名(通常為 'nobody')來訪問檔案。不計入安全模式的限制。

例子 1. is_readable() 例子

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

注: 本函數的結果會被暫存。更多訊息參見 clearstatcache()

提示: PHP 5.0.0 起本函數也可被某些 URL wrapper 使用。參考附錄 M 來看哪些 wrapper 支援 stat() 系列函數的功能。

參見 is_writable()file_exists()fgets()