$file = fopen("example.txt", "w"); // Open a file for writing $txt = "This is some text that will be written to the file"; fwrite($file, $txt); // Write to the file fclose($file); // Close the file
$file = fopen("example.txt", "a"); // Open a file for appending $txt = "This text will be appended to the file"; fwrite($file, $txt); // Write to the file fclose($file); // Close the file
$txt = "This is some text that will be written to the file"; file_put_contents("example.txt", $txt);Package/Library: Core PHP