fwrite() function writes string to the file.
Its syntax is: int fwrite (int filepointer, string string [, int length])
Writing stops either after length characters have been written or after the end of string has been reached.
$data = "data";
$filename = "data.txt";
if ( is_writeable($filename) ) :
$fh = fopen($filename, "a+");
$success = fwrite($fh, $data);
print "Could not open $filename for writing";
Related examples in the same category