PHP/File Directory/is file

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

A File or a Directory?

   <source lang="html4strict">

<? if ( is_file( "data.txt" ) ) {

 print "test.txt is a file!";

} ?>

 </source>
   
  


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

   <source lang="html4strict">

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;

?>

 </source>