The is_readable() function checks whether the specified file is readable.
PHP is_readable() Function has the following syntax.
is_readable(file)
Parameter | Is required | Description |
---|---|---|
file | Required. | File to check |
This function returns TRUE if the file is readable.
The result of this function are cached. Use clearstatcache() to clear the cache.
is_readable() returns true if the string parameter is readable.
For example, to check whether a file is readable:
<?PHP//from w ww .j ava 2s. c om
$filename = 'c:\boot.ini'; // Windows
$filename = '/etc/passwd'; // Unix
if (is_readable($filename)) {
print file_get_contents($filename);
} else {
print 'File not readable!';
}
?>
The code above generates the following result.