Application example of function is_dir() to detect whether directory exists
WBOYOriginal
2016-07-25 09:00:45843browse
var_dump(is_dir('a_file.txt')) . "n";
var_dump(is_dir('bogus_dir/abc')) . "n";
var_dump(is_dir('.. ')); //one dir up
?>
Copy code
output:
bool(false)
bool(false)
bool(true)
Example 2:
$file = "images";
if(is_dir($file))
{
echo ("$file is a directory");
}
else
{
echo ( "$file is not a directory");
}
?>
Copy the code
output:
images is a 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