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

SplFileInfo::isFile

PHP function Edit on GitHub ✎

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

Tells if the object references a regular file

Description

SplFileInfo::isFile(): bool

Checks if the file referenced by this SplFileInfo object exists and is a regular file.

Parameters Parameters

Return Values

Returns true if the file exists and is a regular file (not a link), false otherwise.

Examples

SplFileInfo::isFile() example

php
<?php
$info = new SplFileInfo(__FILE__);
var_dump($info->isFile());

$info = new SplFileInfo(dirname(__FILE__));
var_dump($info->isFile());
?>

The above example will output something similar to:

output
bool(true)
bool(false)

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