PHP is_file()Functions
Complete PHP Filesystem Reference
Definition and Usage
The is_file() function checks whether the specified file is a regular file.
If the file is a regular file, the function returns TRUE.
Syntax
is_file(file)
| Parameters | Description |
|---|---|
| file | Required. Specifies the file to check. |
Tips and Notes
Note:The results of this function are cached. Use clearstatcache() to clear the cache.
Examples
<?php
$file = "test.txt";
if(is_file($file))
{
echo ("$file is a regular file");
}
else
{
echo ("$file is not a regular file");
}
?>
$file = "test.txt";
if(is_file($file))
{
echo ("$file is a regular file");
}
else
{
echo ("$file is not a regular file");
}
?>
The code above will output:
test.txt is a regular file
Complete PHP Filesystem Reference Other Extensions