Latest web development tutorials

PHP is_file () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

Are is_file () function checks the specified file is a regular file.

If the file is a regular file, the function returns TRUE.

grammar

is_file(file)

参数 描述
file 必需。规定要检查的文件。


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");
}
?>

The code above will output:

test.txt is a regular file


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual