php8.5
Home/ Manual/ filesystem / functions/ is_file

is_file

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Tells whether the filename is a regular file

Description

is_file(string $filename): bool

Tells whether the given file is a regular file. If filename is a symbolic link, it will resolve the symlink and will give information about the referred file.

Parameters

filename

Path to the file.

Return Values

Returns true if the filename exists and is a regular file, false otherwise.

32bit

Errors/Exceptions Failure

Examples

is_file() example

php
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>

The above example will output:

output
bool(true)
bool(false)

Notes Clearstatcache Stat

See Also

Source: reference/filesystem/functions/is-file.xml · from the official PHP manual (php/doc-en)