File Handling in PHP is not complex as in C or other languages

  1. The First Step is we create a "handle" variable to handle the connection.
  2. In fopen() function we pass in 2 parameters 'thefilename' and the mode
  3. fwrite() takes in two parameters the handle variable and the data
  4. Consecutive fwrite() will write the data in the same line so if we want in separate lines we use the "\n"
  5. 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 !


Sathesh BM

About Sathesh Bm

Sathesh Bm has written 26 post in this website.

Engineer, Web Lover, Thinker, Blogger

Related Posts Plugin for WordPress, Blogger...