is_readable()
is_readable() — Tells whether a file exists and is readable.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
is_readable(string $filename): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $filename | string | Path to the file. |
Return value
Returns true if the file or directory specified by filename exists and is readable, false otherwise.
Example
A runnable snippet:
$filename = 'test.txt'; if (is_readable($filename)) { echo 'The file is readable'; } else { echo 'The file is not readable'; }
See also
is_writable(), file_exists(), fgets()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page is_readable() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.