The is_dir() function checks whether the specified file is a directory.
PHP is_dir() Function has the following syntax.
is_dir(file)
Parameter | Is Required | Description |
---|---|---|
file | Required. | File to check |
This function returns TRUE if the directory exists.
The result of this function are cached. Use clearstatcache() to clear the cache.
is_dir() returns true if the string parameter is a directory.
For example, to check whether it is a directory:
<?PHP/*from ww w . j a v a2 s. 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.