PHP Tutorial - 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 .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.