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

ParameterIs requiredDescription
fileRequired.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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions