Write data to a text file in php

Write data to a text file
Description

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





$your_data = "This is the data to be stored in the text file.";



// Open the file and erase the contents if any

$fp = fopen("textfile_name.txt", "w");



// Write the data to the file

fwrite($fp, $your_data);



// Close the file

fclose($fp);



?>

Posted in |