In this article, you will learn how to check if a file is readable or not in PHP. The is_readable() function in PHP checks whether the specified filename is readable.
what is the syntax of the is_readable function in php?
is_readable(file)
Parameter | Description |
---|---|
file | Required. Specifies the path to the file to check |
examples of the is_readable function
Example 1. In this example, we check whether the specified filename is readable.
<?php
$file = "test.txt";
if(is_readable($file)) {
echo ("$file is readable");
} else {
echo ("$file is not readable")
}
?>