PHP AdvancedLesson 34Free preview
PHP File Create/Write
This lesson is part of PHP · All levels
Summary
PHP can create new files and write data into them, for example to store log or export results. This lesson discusses fwrite(), file_put_contents(), and the differences between w (time) and a (plus) modes. It should be noted that w mode will delete all the old contents of the file.
Key points
- Write the text to the file in one step
- Write a string to the file that's already opened
- W mode overlaps the old content, a mode adds to the end of the file
- Check the writing results and handle the failures properly
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.