Prikazi cijelu temu 05.03.2012 21:24
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Lokacija:Tuzla


Predmet:Kako otvoriti txt file
PreuzmiIzvorni kôd (HTML):
  1.  <body>
  2.  
  3.  <?php
  4. $file=fopen("welcome.txt","r");
  5. ?>
  6.  
  7.  </body>
  8.  </html>

Opcije:
ModesDescription
rRead only. Starts at the beginning of the file
r+Read/Write. Starts at the beginning of the file
wWrite only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+Read/Write. Opens and clears the contents of file; or creates a new file if it doesn't exist
aAppend. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+Read/Append. Preserves file content by writing to the end of the file
xWrite only. Creates a new file. Returns FALSE and an error if file already exists
x+Read/Write. Creates a new file. Returns FALSE and an error if file already exists
Sljedeći primjer generira poruku ako fopen () funkcija nije u mogućnosti da biste otvorili navedenu datoteku:
PreuzmiIzvorni kôd (HTML):
  1.  <body>
  2.  
  3.  <?php
  4. $file=fopen("welcome.txt","r") or exit("Unable to open file!");
  5. ?>
  6.  
  7.  </body>
  8.  </html>
Fclose () funkcija koristi se da biste zatvorili otvorenu datoteku:
Primjer:
PreuzmiIzvorni kôd (PHP):
  1. <?php
  2.  $file = fopen("test.txt","r");
  3.  
  4.  //some code to be executed
  5.  
  6.  fclose($file);
  7.  ?>

Podrška samo putem foruma, jer samo tako i ostali imaju koristi od toga.