php8.5
Home/ Manual/ spl / splfileinfo/ SplFileInfo::isDir

SplFileInfo::isDir

PHP function Edit on GitHub ✎

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

Tells if the file is a directory

Description

SplFileInfo::isDir(): bool

This method can be used to determine if the file is a directory.

Parameters Parameters

Return Values

Returns true if a directory, false otherwise.

Examples

SplFileInfo::isDir() example

php
<?php
$d = new SplFileInfo(dirname(__FILE__));
var_dump($d->isDir());

$d = new SplFileInfo(__FILE__);
var_dump($d->isDir());
?>

The above example will output something similar to:

output
bool(true)
bool(false)

Source: reference/spl/splfileinfo/isdir.xml · from the official PHP manual (php/doc-en)