In this tutorial we provide a basic example of php file_put_contents, file_get_contents and fopen to create and update a text file. We then update the text file with file_put_contents.
nice video but i have a question. in this video you overwrite the txt file. but i want to add more data in text file and dont want to delete existing data
Good day. I looked at your tutorial and managed to do everything except for one small problem. I converted the textarea into an input field. That all worked out. however, I need 2 input options that both write in the log.txt. So far I haven't found a solution to this.
Hi Finn, really very easy when you know how. Maybe string concatenation is the direct that you need. stackoverflow.com/questions/24780677/file-put-contents-with-multiple-variables
Thank you for this video! I have a question how do i have to store multiple inputs separated with a “ ,” . And i wanna store each user info on a separate line?
@@veryacademy i mean the user have to enter his name, family name, school name . The php should store these info separated by “ ,” in the txt file. And each line represents a different user and their info
My two cents for anyone interested: file_put_contents can accept a third parameter "flag". You can specify if you want the file to keep adding data instead of erasing it (like a log, a list, etc). In the example of this video, it will be something like this: file_put_contents($file, $comment, FILE_APPEND); For more info about file_put_contents() you can visit the php wiki and see the technical stuff as well as the examples.