PHP Append File

PHP Append File

fwrite() - used to writes and append the contents of string to the file stream pointed to by handle.

<?php 
  $file_name = "c:\folder\resource.txt";
  $handle = fopen($file_name, "a");
  fwrite($handle, 'Lorem ipsum dolor sit amet, ');
  fwrite($handle, 'consectetur adipiscing elit');
  fclose($handle);
?>

Output:

Lorem ipsum dolor sit amet, consectetur adipiscing elit