English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The is_dir() function can check if the specified file is a directory. If the directory exists, this function can return true.
bool is_dir ( string $filename )
This function can determine whether the given filename is a directory.
<?php $file = "/PhpProject/php"; if(is_dir($file)) { echo ("$file is a directory"); } else { echo ("$file is not a directory"); } ?>
Output Result
/PhpProject/php is a directory
<?php var_dump(is_dir("/PhpProject/simple.txt")); var_dump(is_dir("/PhpProject/php")); var_dump(is_dir("..")); ?>
Output Result
bool(false) bool(true) bool(true)