This will open a plain text file (.txt) and save information to it.

<?php
$filename = "textfile_name.txt";
$your_data = "This is the data to be stored in the text file.";
// Open the file and erase the contents if any
$fp = fopen($filename, "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
?>