Is_dir () function User Guide in PHP and is_dir User Guide
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
<? 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
<? Php $ 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.