PHP/File Directory/is file

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

A File or a Directory?

 
<?
if ( is_file( "data.txt" ) ) {
  print "test.txt is a file!";
}
?>



is_file() function returns true if file exists and is a readable/writable file.

 
bool is_file (string file)
<?
    $file = "data.txt";
    if (is_file($file)) :
         print "The file $file is valid and exists!";
    else :
         print "Either $file does not exist or it is not a valid file!";
    endif;
?>