I want to add content to file on every page load, but it overwrite file, not updating content. my original code:
$file_handle = fopen('log.txt', 'w');
fwrite($file_handle, $message);
fclose($file_handle);
After i searching, nothing found to solve my prolem:
How to edit/update a txt file with php
PHP Modify a single line in a text file
I used w+
and r+
but it didn't work.
$file_handle = fopen('log.txt', 'w+');
fwrite($file_handle, $message);
fclose($file_handle);
Both write file with new content, not keep old contents. I want to keep old contents, just append new content to existing file.