    ,   -   .     ,     .      Windows     (/),    (\) .        .

          fopen:

  int fopen(string filename, string mode [, int use_include_path])

  filename -       .     ,       .

  mode   ,          :

r (    ;        );
r+ (     ;        );
w (      ;            );
w+ (      ;            );
a (   ;      );
a+ (      ;      );
b (,    (  )   ;    Windows).
   use_include_path        include_path. ( include_path    php.ini).

    ,  fopen   ,    - false.        ,          .          ,        .

,  ,   C:/WWW/HTML/file.txt  :

<?
  $file = fopen("c:/www/html/file.txt","r");
  if(!file)
  {
  echo("  ");
  }
?>

  ,  ,     ,    b:

<?
  $file = fopen("c:/www/html/river.jpg","rb");
  if(!file)
  {
  echo("  ");
  }
?>

2  



          fpassthru:

  int fpassthru (int file)

 file    .

<?
  $file = fopen("c:/www/html/pavlovo.jpg","rb");
  if(!file)
  {
  echo("  ");
  }
  else
  {
  fpassthru($file);
  }
?>

        readfile:

  readfile (string filename)

    ,         ,    :

<?
  readfile ("file.txt");
?>


3  



 ,         .       fclose:

  int fclose (int file)

 file    ,   .


4       



  
         fread:

  string fread ( int file, int length )

     length      file.

 (  ):

<?
  $file = fopen("c:/www/html/file.txt","r");
  if(!file)
  {
  echo("  ");
  }
  else
  {
  $buff = fread ($file,100);
  print $buff;
  }
?>

        fgets:


  string fgets ( int file, int length)

       length - 1 .  ,       .        .

        HTML   fgetss:


  string fgetss (int file, int length [, string allowable_tags])

   allowable_tags      ,     ,        .

      ,   file:


  array file (string filename [, int use_include_path])

     filename   ,        .        ,       .

<?
  $file_array = file("file.txt");
  if(!$file_array)
  {
  echo("  ");
  }
  else
  {
  for($i=0; $i < count($file_array); $i++)
  {
  printf("%s<br>", $file_array[$i]);
  }
  }
?>

    ,           :

<?
  $file_array =  file ("file.txt");
  if(!$file_array)
  {
  echo("  ");
  }
  else
  {
  $num_str =  count($file_array);
  echo($num_str);
  }
?>

,   file       .

     *.csv   fgetcsv:

  array fgetcsv ( int file, int length, char delim)

          delim.  delim       ,         .      false,    .      ,        -  .  length       ,      fgets.

 CSV    ,      MSExcel.       MSExcel  file.csv,   .

<?
  $count = 1;
  $file =  fopen ("file.csv","r");
  while ($data = fgetcsv ($file, 1000, ","))
  {
  $num = count ($data);
  $count++;
  for ($i=0; $i < $num; $i++)
  {
  print "$data[$i]<br>";
  }
  }
  fclose ( $file );
?>



  
     fputs  fwrite,   :

  int fputs ( int file, string string [, int length ])
  int fwrite ( int file, string string [, int length ])

  -  ,    .     ,      .        ,    .     ,   .

     "file.txt"   "Hello, world!"

<?
  $file = fopen ("file.txt","r+");
  $str = "Hello, world!";
  if ( !$file )
  {
  echo("  ");
  }
  else
  {
  fputs ( $file, $str);
  }
  fclose ($file);
?>

5 ,    



    copy:

  int copy ( string file1, string file2)

     file1     file2.   file2    ,   .

      rename:

  int rename ( string old, string new)

      old     new.

 rename    ,         .

     unlink:


  int unlink ( string filename)

6  



            .

 file_exists ,      true,     false   :

  bool file_exists ( string filename)

 fileatime      :

  int fileatime ( string filename)

 filemtime      :

  int filemtime ( string filename)

 file_size     :

  int file_size ( string filename)

 file_type   :

  string file_type ( string filename)

,   ,      :

char (  );
dir ();
fifo ( );
link ( );
block (  );
file ( );
unknown (  ).
  ,   ,  ,        , PHP    .        clearstatcache:

<?
  clearstatcache();
?>

7   



            .   ,        .

         rewind:

  int rewind ( int file)

 file   .

        ftell:

  int ftell ( int file)

      ,   fseek:

  int fseek ( int file, int offset [, int whence ])

 fseek        offset (  ,       ,      whence).  file    .  whence       offset       :

SEEK_SET (   );
SEEK_CUR (     );
SEEK_END (    ).
   whence   SEEK_SET.

,      ,     feof:

  int feof ( int file)

     ,   true,     false.

 feof     :

<?
  $file = fopen ("file.txt","r");
  if ($file)
  {
  while(!feof($file))
  {
  $str = fgets($file);
  echo $str;
  echo ("<br>");
  }
  fclose ( $file);
  }
  else
  {
  echo("  ");
  }
?>

          :

<?
  $file = fopen ("file.txt","r");
  if ($file)
  {
  $counter = 0;
  while(!feof($file))
  {
  $str = fgets ($file);
  $counter++;
  }
  echo($counter);
  fclose ($file);
  }
  else
  {
  echo("  ");
  }
?>


8   



      chdir:

  int chdir ( string directory)

      :

chdir("/tmp/data"); //    
chdir("./js"); //     
chdir(".."); //    
chdir("~/data"); //   /home//data ( Unix)
       getcwd:

  string getcwd ( string path)

       opendir,  ,   path:

  int opendir ( string path)

 ,   ,     readdir:

  string readdir ( int dir)

    ,   .          "."  "..".      ,   -  .  , ,  ,     ".":

  $dir = opendir (".");

 ,     ,   .       closedir:

  void closedir ($dir)

  ,     ,    .

<?
  $dir = opendir (".");
  echo "Files:\n";
  while ($file = readdir ($dir))
  {
  echo "$file<br>";
  }
  closedir ($dir);
?>

,      "."  "..".     ,       :

<?
  $dir = opendir (".");
  while ( $file = readdir ($dir))
  {
  if (( $file != ".") && ($file != ".."))
  {
  echo "$file<br>";
  }
  }
  closedir ($dir);
?>

     ,   ,      c:/temp,        .        .

<?
  function delTemporaryFiles ($directory)
  {
  $dir = opendir ($directory);
  while (( $file = readdir ($dir)))
  {
  if( is_file ($directory."/".$file))
  {
  $acc_time = fileatime ($directory."/".$file);
  $time =  time();
  if (($time - $acc_time) > 24*60*60)
  {
  if (  unlink ($directory."/".$file))
  {
  echo ("  ");
  }
  }
  }
  else if ( is_dir ($directory."/".$file) && ($file != ".") && ($file != ".."))
  {
  delTemporaryFiles ($directory."/".$file);
  }
  }
  closedir ($dir);
  }
  delTemporaryFiles ("c:/temp");
?>

      mkdir:

  bool mkdir ( string dirname, int mode)

      dirname    mode.     false.       UNIX,   Windows   .      test   c:/temp.

<?
  $flag = mkdir ("c:/temp/test", 0700);
  if($flag)
  {
  echo("  ");
  }
  else
  {
  echo("  ");
  }
?>

      rmdir:

  bool rmdir ( string dirname)

      /test:

<?
  $flag = rmdir ("c:/temp/test");
  if($flag)
  {
  echo("  ");
  }
  else
  {
  echo("  ");
  }
?>

 rmdir    .      ,       c:/temp      :

<?
  function full_del_dir ($directory)
  {
  $dir = opendir($directory);
  while(($file = readdir($dir)))
  {
  if ( is_file ($directory."/".$file))
  {
  unlink ($directory."/".$file);
  }
  else if ( is_dir ($directory."/".$file) &&
  ($file != ".") && ($file != ".."))
  {
  full_del_dir ($directory."/".$file);
  }
  }
  closedir ($dir);
  rmdir ($directory);
  echo("  ");
  }
  full_del_dir ("c:/temp")
?>

          "."  "..",      ,          .         .

9  PUT  POST



 HTTP PUT  HTTP POST      .

 HTTP       ,   Web-: GET, PUT  POST.  GET    Web-,        URL.    Web-      URL ( ,   1024),     GET,      .

 PUT      ,  ,    HTTP PUT   .    :

  PUT /path/filename.html HTTP/1.1

   Web-        /path/filename.html    URL Web-.    Web-    ,   CGI-   .  Apache     PUT-,    Script,    httpd.conf,  , :

  Script PUT /cgi-bin/put.cgi

 ,   PUT-  CGI- put.cgi.

 ,        HTTP POST.                 .