cookspyder Posted July 23, 2007 Share Posted July 23, 2007 looking to write to a file with out overwriting the previous data? is there a way to turn overwrite off with the file put contents?? im trying to keep a log of form data. Link to comment https://forums.phpfreaks.com/topic/61424-file-put-contents/ Share on other sites More sharing options...
Wildbug Posted July 23, 2007 Share Posted July 23, 2007 Try the FILE_APPEND flag. Link to comment https://forums.phpfreaks.com/topic/61424-file-put-contents/#findComment-305691 Share on other sites More sharing options...
stlewis Posted July 24, 2007 Share Posted July 24, 2007 Just open the log file in apend mode; fopen($file,"a+"); Whatever you write to the existing file is placed at the end...done. Link to comment https://forums.phpfreaks.com/topic/61424-file-put-contents/#findComment-305850 Share on other sites More sharing options...
Wildbug Posted July 24, 2007 Share Posted July 24, 2007 file_put_contents("filename",$variable, FILE_APPEND) will do it in one shot, though; you don't need to fopen/fwrite/fclose. Link to comment https://forums.phpfreaks.com/topic/61424-file-put-contents/#findComment-305876 Share on other sites More sharing options...
stlewis Posted July 26, 2007 Share Posted July 26, 2007 Hmm...I didn't know that, and it's much more efficient... Link to comment https://forums.phpfreaks.com/topic/61424-file-put-contents/#findComment-308108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.