PHP is_dir() 判断给定文件名是否是一个目录_PHP教程

WBOY
Release: 2016-07-21 15:38:11
Original
835 people have browsed it

说明
boolis_dir( string $filename )
如果文件名存在并且为目录则返回 TRUE。如果 filename 是一个相对路径,则按照当前工作目录检查其相对路径。

Note: 本函数的结果会被缓存。更多信息参见 clearstatcache()。

is_dir() 例子1

复制代码代码如下:


var_dump(is_dir('a_file.txt')) . "\n";
var_dump(is_dir('bogus_dir/abc')) . "\n";
var_dump(is_dir('..')); //one dir up
?>

上例将输出:

bool(false)
bool(false)
bool(true)

is_dir()例子2
复制代码代码如下:

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

输出:
如果存在images这个目录,则输出如下。
images is a directory

www.bkjia.com true http://www.bkjia.com/PHPjc/321795.html TechArticle 说明 bool is_dir ( string $filename ) 如果文件名存在并且为目录则返回 TRUE。如果 filename 是一个相对路径,则按照当前工作目录检查其相对路径。...
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!