PHP 5.6.16 is available


(PHP 4, PHP 5, PHP 7)

is_readableTells whether a file exists and is readable


bool is_readable ( string $filename )

Tells whether a file exists and is readable.



Path to the file.

Valorile întoarse

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


Example #1 is_readable() example

if (
is_readable($filename)) {
'The file is readable';
} else {
'The file is not readable';


În cazul eșecului este emis un E_WARNING.


Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 'nobody'). Safe mode limitations are not taken into account before PHP 5.1.5.

Notă: Rezultatele acestei funcții sunt stocate în cache. Accesați clearstatcache() pentru mai multe detalii.


Începând cu PHP 5.0.0 această funcție poate fi utilizată de asemenea cu unele învelișuri URL. Referiți-vă la Supported Protocols and Wrappers pentru a determina care învelișuri susțin familia de funcționalitate stat().


The check is done using the real UID/GID instead of the effective one.

This function may return TRUE for directories. Use is_dir() to distinguish file and directory.

A se vedea și

add a note add a note

User Contributed Notes 3 notes

jo at durchholz dot org
9 years ago
DrTebi at yahoo dot com is wrong. is_readable() checks whether you can do file_get_contents() or similar calls, no more, no less. If the location given returns a 500 or 403 error, you can still read() that (you'll simply get the error page), but it's still read()able. Using is_readable to check the validity of a URL is simply the wrong function.
pgl at yoyo dot org
6 years ago
Note that is_readable() will return false for streams, eg, php://stdin.
10 years ago
Sometimes in situations where file_exists fails (returns false even though the file does exist) stat will work.
To Top