Source Code : PHP 5 Arguments for Opening a File

PHP Is Open Source Programming Language You Can Download and use It, You required xampp server and wamp server . You download From xampp server from https://www.apachefriends.org/download.html. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://php.net/. Click Here or search from google with Libraries Name you get jar file related it and also http://php.net/ is a official site

PHP 5 Arguments for Opening a File

 
Argument        Description 
r               Opens a file for reading 
r+              Opens a file for both reading and writing 
w               Opens a file for writing only 
w+              Opens a file for reading and writing 
a               Opens a file for appending (write-only) 
a+              Opens a file for appending (read/write) 
X               Creates a file and opens it for writing only 
x+              Creates a file and opens it for reading and writing 


<?php 
$file = "data.txt"; 
if (file_exists ($file)){ 
    try { 
        if ($readfile = fopen ($file, "r")){ 
            $curvalue = fread ($readfile,100); 
            echo $curvalue; 
        } else { 
            throw new exception ("the file could not be opened."); 
        } 
    } catch (exception $e) { 
        echo $e->getmessage(); 
    } 
} else { 
    echo "File does not exist."; 
} 
?>
  
  

Thank with us