Predmet:Kako otvoriti txt file
   
PreuzmiIzvorni kôd (HTML):
-   
-  <?php 
-  $file=fopen("welcome.txt","r"); 
-  ?> 
-   
 
Opcije:
| Modes | Description | 
|---|
| r | Read only. Starts at the beginning of the file | 
| r+ | Read/Write. Starts at the beginning of the file | 
| w | Write 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 | 
| a | Append. 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 | 
| x | Write 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):
-   
-  <?php 
-  $file=fopen("welcome.txt","r") or exit("Unable to open file!"); 
-  ?> 
-   
 Fclose () funkcija koristi se da biste zatvorili otvorenu datoteku:
Primjer:
PreuzmiIzvorni kôd (PHP):- <?php 
-  $file = fopen("test.txt","r"); 
-   
-  //some code to be executed 
-   
-  ?> 
    
     Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.