is_readable

(PHP 3, PHP 4, PHP 5)

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

说明

bool is_readable ( string filename )

如果文件存在并且可读则返回 TRUE

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

例子 1. is_writable() 例子

<?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 使用。参考 附录 L 来看哪些 wrapper 支持 stat() 系列函数的功能。

参见 is_writable() file_exists() fgets()