In this article, you will learn how to check if a file is a regular file. The is_file() function in PHP checks whether the specified filename is a regular file.
what is the syntax of the IS_FILE function in php?
is_file(file)
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to check |
examples of the IS_FILE function
Example 1. In this example, we 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");
}
?>