PHP is_dir()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

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

If the directory exists, the function returns TRUE.

Syntax

is_dir(file)

Parameters Description
file Required. Specifies the file to check.


Tips and Notes

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


Examples

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

The above code will output:

images is a directory


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions