$file = "example.txt"; $data = "This is a test.\n"; file_put_contents($file, $data, FILE_APPEND);
$file = "example.txt"; $data = "This is a test.\n"; $handle = fopen($file, 'a') or die("Cannot open file: ".$file); fwrite($handle, $data); fclose($handle);This code appends the text "This is a test." into a file named "example.txt" as well. The package/library that provides these functions is the core PHP library.