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
Parameter | Is Required | Description |
---|---|---|
file | Required. | 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.