Appending to a file : fwrite « File Directory « PHP






Appending to a file

 
<?php  

  # for Linux use...
  # $filename = "/home/mike/Desktop/newfile.txt";

  # for Windows use...
  $filename = "C:\\newfile.txt";

  $file = fopen( $filename, "a" );
  $string = "\t\t\tOctober 13,2010";

  fwrite( $file, $string );
  fclose( $file );
?>

<html>

 <head>
  <title>Appending to a file</title>
 </head>

 <body>

 <?php
  $file_length = filesize( $filename );
  echo( "$filename is now $file_length bytes" );
 ?>

 </body>

</html>
  
  








Related examples in the same category

1.A simple access counter
2.fwrite() function writes string to the file.
3.fwrite.php
4.Using file-related error information
5.Writing data to a file
6.Storing user information in a text file