File Handling in PHP is not complex as in C or other languages
- The First Step is we create a "handle" variable to handle the connection.
- In fopen() function we pass in 2 parameters 'thefilename' and the mode
- fwrite() takes in two parameters the handle variable and the data
- Consecutive fwrite() will write the data in the same line so if we want in separate lines we use the "\n"
- Then we close the handle using fclose() function.
The Snippet is Given Below
The Output will be Sathesh in one line and Bm in another line on the newly created file 'names.txt' as below
- Click below to download the Script
Thank u for reading this Article hope it was useful !