Skip to content

Instantly share code, notes, and snippets.

@freshsnippets
Created May 3, 2012 03:12
Show Gist options
  • Save freshsnippets/2582757 to your computer and use it in GitHub Desktop.
Save freshsnippets/2582757 to your computer and use it in GitHub Desktop.
PHP: Append to a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment