Guidelines for using the Is_dir () function in PHP
PHP provides built-in function is_dir to check if the passed-in Path parameter is a directory and returns true if it is a directory. This means that the parameter passed in is either a file or not, so the current parameter cannot be said to be a folder or a file. It is also important to note that the parameters support relative paths and absolute paths.
Function: Is_dir ()
Function: Determine if a given file name is a directory
Description
BOOL Is_dir (String $filename)
Returns TRUE if the file name exists and is a directory.
If filename is a relative path, the relative path is checked according to the current working directory.
Note: The result of this function is cached. See Clearstatcache () for more information.
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 example above 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 directory exists images, the output is:
Images is a directory
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/996756.html www.bkjia.com true http://www.bkjia.com/PHPjc/996756.html techarticle php is_dir () function using the Guide PHP provides built-in function Is_dir to check whether the passed path parameter is a directory, and if it is a directory, returns TRUE. This means that the parameter passed in is a file or not ...