PHP is_dir() Function
Definition and Usage
The is_dir() function checks whether the specified file is a directory.
Syntax
is_dir(file)
Parameter | Description |
---|---|
file | Required. Specifies the file to be checked. |
Description
If the filename exists and is a directory, it will return true. If file If it is a relative path, it will check the relative path according to the current working directory.
Tips and Comments
Note:The result of this function will be cached. Please use clearstatcache() to clear the cache.
Example
<?php $file = "images"; if(is_dir($file)) { echo("$file is a directory"); } else { echo("$file is not a directory"); } ?>
Output:
images is a directory