php is_dir()函数介绍

is_dir — 判断给定文件名是否是一个目录

语法:

bool is_dir ( string $filename )

判断给定文件名是否是一个目录。 

参数:

  1. filename 如果文件名存在并且为目录则返回 TRUE。如果 filename 是一个相对路径,则按照当前工作目录检查其相对路径。 If filename is a symbolic or hard then the will be resolved and checked. If you have enabled 安全模式, or open_ dir further restrictions may apply. 

返回值:

如果文件名存在,并且是个目录,返回 TRUE,否则返回FALSE。

 

php is_dir()实例

使用is_dir()函数判断是否为目录

is_dir() function verifies that the file is a directory

bool is_dir (string filename)

<?
    $isdir = is_dir(\"index.html\"); // returns false
    /* http://www.manongjc.com/article/1366.html */
    $isdir = is_dir(\"book\"); // returns true
?>
收藏 打印