The is_file() function checks whether the specified file is a regular file.
PHP is_file() Function has the following syntax.
is_file(file)
Parameter | Is required | Description |
---|---|---|
file | Required. | File to check |
This function returns TRUE if it is a file.
The result of this function are cached. Use clearstatcache() to clear the cache.
is_file() returns true if the string parameter is a file.
For example, to check whether it is a file:
<?PHP//from w w w .j a va 2s.c o m
$filename = 'c:\boot.ini'; // Windows
$filename = '/etc/passwd'; // Unix
if (is_file($filename)) {
print 'is File !';
} else {
print 'is not a File!';
}
?>
The code above generates the following result.