PHP/File Directory/is readable

Материал из Web эксперт
Перейти к: навигация, поиск

is_readable

 
<?php
$file_name="permissions.php";
if(is_readable($file_name)) {
    echo ("The file $file_name is readable.<br />");
}
else {
    echo ("The file $file_name is not readable.<br />");
}
?>



is_readable() function checks the readability of both a file and a directory.

 
Its syntax is: bool is_readable (string filename)
<?
$filename="data.txt";
if ( is_readable($filename) ) :
     $fh = fopen($filename, "r");
else :
     print "$filename Is not readable!";
endif;
?>



is_readable() tells you whether you can read a file.

 
<?
if ( is_readable( "data.txt" ) ) {
  print "data.txt is readable";
}
?>