PHP is_dir () function User Guide. In PHP, the is_dir () function usage guide php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, the input parameters are files or is_dir () function usage instructions in PHP.
Php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, if the input parameter is a file or does not exist, it is false. Therefore, the current parameter cannot be used as a folder or a file. In addition, you must note that parameters support relative paths and absolute paths.
Function: is_dir ()
Function: determines whether the specified file name is a directory.
Note:
Bool is_dir (string $ filename)
Returns TRUE if the file name exists and is a directory.
If filename is a relative path, check its relative path according to the current working directory.
Note: the result of this function is cached. For more information, see clearstatcache ().
Example 1
?
|
1
2
3
4
5 |
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)
Example 2
?
|
1
2
3
4
5
6
7
8
9
10
11 |
$ 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 is:
Images is a directory
The above is all the content of this article. I hope you will like it.
Usage () function guide php provides the built-in function is_dir to check whether the input path parameter is a directory. if it is a directory, true is returned. That is to say, the input parameter is a file or not...