PHP file_put_contents - Add and Update a Text File

Поділитися
Вставка
  • Опубліковано 28 січ 2025

КОМЕНТАРІ • 23

  • @youarelovedbylovehimself.6250
    @youarelovedbylovehimself.6250 4 роки тому +2

    Thank you for taking your time to share your knowledge

  • @jonaspeters8648
    @jonaspeters8648 2 роки тому +1

    Thank you for the video.
    Do we need two php files for that, or is it possible in one php file?

  • @villagerstown
    @villagerstown 3 роки тому +1

    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

    • @veryacademy
      @veryacademy  3 роки тому

      stackoverflow.com/questions/103593/using-php-how-to-insert-text-without-overwriting-to-the-beginning-of-a-text-fil

  • @finnschnellenberg8374
    @finnschnellenberg8374 2 роки тому +1

    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.

    • @veryacademy
      @veryacademy  2 роки тому

      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

  • @christianlanoire7541
    @christianlanoire7541 3 роки тому

    Thank you!!, but where is the place to close the file? imagine we create and update many files, what would happen with the memory?

  • @Henry_Nunez
    @Henry_Nunez 3 роки тому

    Se puede hacer sin localhost ?? 👉 NO QUIERO USAR XAMPP

  • @ATRcs22
    @ATRcs22 3 роки тому +2

    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.

    • @veryacademy
      @veryacademy  3 роки тому

      Thanks Emanuel, I forgot about this tutorial!

    • @ATRcs22
      @ATRcs22 3 роки тому +1

      @@veryacademy thanks to you man, your tutorial saved me. Cheers from Argentina

  • @saraaboshousha
    @saraaboshousha 3 роки тому +2

    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
      @veryacademy  3 роки тому

      Hi Sara, sorry, not quite sure as to what you mean by store multiple inputs and store each user info on a separate line - store it where?

    • @saraaboshousha
      @saraaboshousha 3 роки тому

      @@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

    • @bronsondavion466
      @bronsondavion466 3 роки тому

      i know Im kinda off topic but does anybody know a good site to watch newly released tv shows online?

    • @adrianleandro4315
      @adrianleandro4315 3 роки тому

      @Bronson Davion Flixportal :)

    • @bronsondavion466
      @bronsondavion466 3 роки тому

      @Adrian Leandro Thank you, I signed up and it seems to work :D I appreciate it!

  • @davidholmes4439
    @davidholmes4439 3 роки тому +1

    What program are you using to code?

  • @DivijHere
    @DivijHere 5 місяців тому

    🫶thanks