Menu Home

is_readable

osbo.com | PHP | Functions | is_readable

Tells whether a file exists and is readable

Syntax

is_readable ( string $filename ) : bool

Parameters

filename

Path to the file.

Return

Returns TRUE if the file or directory specified by filename exists and is readable, FALSE otherwise.

Examples

<?

function read($filename)
{
    if (is_readable($filename)) {
        echo "readable\n";
    } else {
        echo "not readable\n";
    }
}

read($_SERVER['DOCUMENT_ROOT'] . '/assets/txt/file.txt');
read('false.txt');

?>
readable
not readable

PHP