How to check if a directory exists in PHP?

To check if a directory exists in PHP, you can use the is_dir() function.

Here's an example:

$directory = '/path/to/directory'; if (is_dir($directory)) { echo "Directory exists"; } else { echo "Directory does not exist"; }

In this example, replace '/path/to/directory' with the actual path of the directory you want to check.

The is_dir() function returns true if the path is a directory and exists, and false otherwise.