File Open modes

text.txt has the following text written in it: Some random text is here to demonstrate the PHP write operators

File writing using 'r+' mode

The following code will be run on a text file

<?php


$handle = fopen('text.txt','r+');
fwrite($handle,"This text will be put into the file using 'r+' ");
fclose($handle);
echo " 'r+' write done";


?>

run php code here

Now look at link again....text.txt

File writing using 'w' mode

The following code will be run on the text file

<?php


$handle = fopen('text.txt',w');
fwrite($handle,'123456789');
fclose($handle);
echo " 'w' write done";


?>

run php file here

Now look at file again....text.txt

reset text file here