This function takes the file path and checks the file system to see if it actually exists. If it does, and if it’s a directory (not just a file), it returns true. If it doesn’t exist or isn’t a directory, false is returned.

// assume the directory "files" has been created in the public_html directory
 
$path  = '/home/admin/public_html/files';
$isDir = is_dir($path); // true
 
$path  = '/home/admin/public_html/files/index.php';
$isDir = is_dir($path); // false

If a relative path is given, it is checked from the current directory. Otherwise, it is checked from the root directory.

// assume we're in /home/admin/public_html
 
$path  = 'files';
$isDir = is_dir($path); // true
 
$path  = '/files';
$isDir = is_dir($path); // false
 
$path  = 'index.php';
$isDir = is_dir($path); // false