Write text to a file
$output_text = "Hello";
file_put_contents("files/output_filename.txt", $output_text); //(Will overwrite an existing file)
Note that the directory you write the file to will need chomd set to 777 (php needs the X bit set to be able to write). This can be a potential security risk if this is a concern.
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.