PHP is_readable() Function
In this chapter you will learn:
- Definition for PHP is_readable() Function
- Syntax for PHP is_readable() Function
- Parameter for PHP is_readable() Function
- Return for PHP is_readable() Function
- Note on PHP is_readable() Function
- Example - checks whether the specified file is readable
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/*j av a2 s. 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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP is_uploaded_file() Function
- Syntax for PHP is_uploaded_file() Function
- Parameter for PHP is_uploaded_file() Function
- Return for PHP is_uploaded_file() Function
- Note for PHP is_uploaded_file() Function
- Example - whether the specified file is uploaded via HTTP POST
Home » PHP Tutorial » PHP File Functions