is_readable

bool is_readable(string filename) 

Checks whether a file is readable.

Returns:

TRUE if readable; FALSE otherwise

Description:

Checks whether the specified file is readable by PHP. Note that depending on how the script is executed (command line, CGI, module), the test may be performed with varying user IDs, so permissions may affect the result of the function. Safe mode restrictions are not taken into account.

Note:

The results of this function are cached. See clearstatcache() for details.

Example:

Check whether a file is readable
$file = "testfile"; 

if(is_readable($file)) 
{
    // open and read from file 
} 
else 
{
    echo ("Cannot read from file $file."); 
} 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.