How to add text to the file : Text File Write : File Directory PHP Source Code


PHP Source Code » File Directory » Text File Write »

 

How to add text to the file




<?php
  $myfile = "./test.txt";
  $openfile = fopen ($myfile,"a"or die ("Couldn't open the file");
  fwrite ($openfile,"Have a nice day! n");
  fclose ($openfile);

  $openfile = fopen ($myfile,"r"or die ("Couldn't open the file");
  $file_size=filesize($myfile);
  $file_contents = fread ($openfile,$file_size);

  $msg ="$file_contents";
  fclose ($openfile);
  echo $msg;
?>
           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo File Directory
» Text File Write