PHP 7 is_file() Function
❮ PHP Filesystem ReferenceExample
Check whether the specified filename is a regular file:
<?php
$file = "test.txt";
if(is_file($file)) {
echo ("$file is a regular file");
} else {
echo ("$file is not a regular file");
}
?>
The output of the code above could be:
test.txt is a regular file
Definition and Usage
The is_file() function checks whether the specified filename is a regular file.
Note: The result of this function is cached. Use clearstatcache() to clear the cache.
Syntax
is_file(file)
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to check |
Technical Details
Return Value: | TRUE if the file is a regular file, FALSE otherwise |
---|---|
PHP Version: | 4.0+ |
❮ PHP Filesystem Reference