PHP is_readable() Function
Definition
The is_readable() function checks whether the specified file is readable.
Syntax
PHP is_readable() Function has the following syntax.
is_readable(file)
Parameter
Parameter | Is required | Description |
---|---|---|
file | Required. | File to check |
Return
This function returns TRUE if the file is readable.
Note
The result of this function are cached. Use clearstatcache() to clear the cache.
Example
is_readable() returns true if the string parameter is readable.
For example, to check whether a file is readable:
<?PHP//from w ww . ja v a 2 s. co m
$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.