In this article, you will learn how to check if the specified name is the name of a file or directory. The is_dir() function in PHP checks whether the specified filename is a directory.
what is the syntax of the IS_DIR function in php?
is_dir(file)
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to check |
examples of the IS_DIR function
Example 1. In this example, we check whether the specified filename is a directory.
<?php
$file = "images";
if(is_dir($file)) {
echo ("$file is a directory");
} else {
echo ("$file is not a directory");
}
?>