is_dir() function in PHP


The is_dir() function checks whether a file is a directory. It returns TRUE if the directory is found.

Syntax

is_dir(file_path)

Parameters

  • file_path − Specify the path of the file.

Return

The is_dir() function returns TRUE if the directory is found.

Example

 Live Demo

<?php
   $check = "D:/tutorials";
   if (is_dir($check))
   echo ("Directory!");
   else
   echo ("Not a directory!");
?>

Output

Not a directory!

Updated on: 24-Jun-2020

103 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements