Eli Tutorials
Part 1: Introduction to PHP Programming
Part 3: Comments and INCLUDE in PHP Programming
Part 4: Variables in Print in PHP Programming
The file_put_contents() function writes a string to a file. It follows a specific ruleset when accessing a file:
A CSV file is a Comma Separated Value file. This type of file can be opened with any spreadsheet program, and the information between comma delimiters will be placed into separates cells.
The link above is the sample code created with Eli's demonstration of printing to files with PHP. The link goes to an HTML form which accepts a user's name and email address. Once the user hits submit, it will go to a PHP page will thank them for submitting their information. The first iteration of this program wrote the information to a .html file that could be viewed in the browser, but the current iteration above writes the information to a .csv file. The CSV file will display names in one column of cells, and email addresses in another column. All of the information is appended, so that the file is not cleared every time it is submitted.