is_readable 判断给定文件名是否可读 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 包装器。请参见 Supported Protocols and Wrappers以获得支持 stat() 系列函数功能的包装器列表。

参见 is_writable()file_exists()fgets()


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3