php check if is directory example

To check if a path in PHP is a directory, you can use the `is_dir()` function:
```php
$path = '/path/to/directory'; if (is_dir($path)) {   echo "$path is a directory"; } else {   echo "$path is not a directory"; }
```
This will output "true" or "false" depending on whether the path is a directory.

Alternatively, you can use the `file_exists()` function to check if the path exists and then check if it's 
a directory:
```php
$path = '/path/to/directory'; if (file_exists($path) && is_dir($path)) {   echo "$path is a directory"; } else {   echo "$path is not a directory"; }
```
You can also use the `is_file()` function to check if the path is a file, and then use the negation 
operator (`!`) to check if it's a directory:
```php
$path = '/path/to/directory'; if (!is_file($path) && is_dir($path)) {   echo "$path is a directory"; } else {   echo "$path is not a directory"; }
```
Note that `is_dir()` returns true for directories and false for files, while `file_exists()` returns true 
if the path exists (regardless of whether it's a file or directory).

Also, you can use the `glob()` function to check if a path is a directory:
```php
$path = '/path/to/directory'; if (glob($path . '/*', GLOB_ONLYDIR)) {   echo "$path is a directory"; } else {   echo "$path is not a directory"; }
```
This will return true if the path is a directory and false otherwise.