Filesystem 函数
PHP 手册

is_readable

(PHP 4, PHP 5)

is_readable判断给定文件名是否可读

说明

bool is_readable ( string $filename )

如果由 filename 指定的文件或目录存在并且可读则返回 TRUE

记住 PHP 也许只能以运行 webserver 的用户名(通常为 'nobody')来访问文件。不计入安全模式的限制。

Example #1 is_readable() 例子

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

Note: 本函数的结果会被缓存。更多信息参见 clearstatcache()

Tip

PHP 5.0.0 起本函数也可被某些 URL wrapper 使用。参考支持的协议/封装协议列表 来看哪些 wrapper 支持 stat() 系列函数的功能。

参见 is_writable()file_exists()fgets()


Filesystem 函数
PHP 手册