Home >Backend Development >PHP Tutorial >PHP is_dir() determines whether the given file name is a directory_PHP tutorial

PHP is_dir() determines whether the given file name is a directory_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:38:11957browse

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

www.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. ...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn