PHP is_file() Function

Definition

The is_file() function checks whether the specified file is a regular file.

Syntax

PHP is_file() Function has the following syntax.

is_file(file)

Parameter

ParameterIs requiredDescription
fileRequired.File to check

Return

This function returns TRUE if it is a file.

Note

The result of this function are cached. Use clearstatcache() to clear the cache.

Example

is_file() returns true if the string parameter is a file.

For example, to check whether it is a file:


<?PHP//ww w. j  a v a 2 s.c o  m
      $filename = 'c:\boot.ini'; // Windows
      $filename = '/etc/passwd'; // Unix

      if (is_file($filename)) {
             print 'is File !';
      } else {
             print 'is not a File!';
      }
      
?>

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