PHP is_dir() Function

Definition

The is_dir() function checks whether the specified file is a directory.

Syntax

PHP is_dir() Function has the following syntax.

is_dir(file)

Parameter

ParameterIs RequiredDescription
fileRequired.File to check

Return

This function returns TRUE if the directory exists.

Note

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

Example

is_dir() returns true if the string parameter is a directory.

For example, to check whether it is a directory:


<?PHP/*  w w  w.jav a2s. co  m*/
      $filename = 'c:\boot.ini'; // Windows
      $filename = '/etc/passwd'; // Unix

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

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