[PHP] Append to a file with file_put_contents

Created on November 30, 2026

Pass FILE_APPEND as the third argument to file_put_contents to add data to the end of the file.

file_put_contents($file_path, $data, FILE_APPEND);
PHP