Function: Is_dir ()
Function: To determine whether a given file name is a directory
Description
bool Is_dir (string $filename)
Returns TRUE if the filename 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 will be cached. See Clearstatcache () for more information.
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 example above 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 there is a images this directory, the output is:
Images is a directory
The above mentioned is the entire content of this article, I hope you can enjoy.