Description
bool is_dir ( string $filename )
Returns TRUE if the filename exists and is a directory. If filename is a relative path, its relative path is checked against the current working directory.
Note: The result of this function will be cached. See clearstatcache() for more information.
is_dir() Example 1
Copy code The code is as follows:
< ;?
var_dump(is_dir('a_file.txt')) . "n";
var_dump(is_dir('bogus_dir/abc')) . "n";
var_dump(is_dir('.. ')); //one dir up
?>
The above example will output:
bool(false)
bool(false)
bool (true)
is_dir() Example 2
Copy code The code is as follows:
$file = "images";
if(is_dir($file))
{
echo ("$file is a directory") ;
}
else
{
echo ("$file is not a directory");
}
?>
Output:
If the images directory exists, the output will be as follows.
images is a directory
http://www.bkjia.com/PHPjc/321795.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321795.htmlTechArticleDescription bool is_dir ( string $filename ) Returns TRUE if the file name exists and is a directory. If filename is a relative path, its relative path is checked against the current working directory. ...