PHP is_dir() Function

❮ PHP Filesystem Reference

Example

Check whether the specified filename is a directory:

<?php
$file = "images";
if(is_dir($file)) {
  echo ("$file is a directory");
} else {
  echo ("$file is not a directory");
}
?>

The output of the code above could be:

images is a directory


Definition and Usage

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

Note: The result of this function is cached. Use clearstatcache() to clear the cache.

Syntax

is_dir(file)

Parameter Values

Parameter Description
file Required. Specifies the path to the file to check


Technical Details

Return Value: TRUE if the directory exists, FALSE otherwise
PHP Version: 4.0+

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.