What is the is_readable() function in PHP?
The is_readable() function in PHP checks whether the given filename is readable.
For the function to label a defined path as readable, the file must both exist and be readable.
Syntax
is_readable(string: $name):bool
Parameters
name: This is the path of the file we want to check.
Return value
is_readable() returns true if the provided path of the file exists and the file is readable. Otherwise, in case of any error, it returns false.
Code
The code below shows how to use the is_readable() function.
main.php
q2.txt
<?php$file1 = "q2.txt";if(is_readable($file1)){echo ("q2 is readable");}else{echo ("q2 is not readable");}?>
Explanation
A file q2.txt is created and passed to the is_readable function. Since the file exists and is readable, it returns true and the above output is produced.
This function produces cache output. So, in order to clear the cache, we invoke the
clearstatcache()function.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved