php is_readable()介绍

is_readable — 判断给定文件名或目录是否可读,该函数的结果会被缓存。请使用 clearstatcache() 来清除缓存。

语法:

bool is_readable  ( string $filename  )

判断给定文件名或目录是否存在并且可读。

参数:

  1. filename 文件的路径。 

返回值:

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

 

php is_readable()实例

使用is_readable()函数判断文件是否可读:

<?php
$file = \"test.txt\";
if(is_readable($file))
{
echo (\"$file is readable\");
}
else
{
/* http://www.manongjc.com/article/1368.html */
echo (\"$file is not readable\");
}
?>

上面的代码将输出:

test.txt is readable
收藏 打印