Mega Code Archive

 
Categories / Php / File Directory
 

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);      fclose($fh); else :      print "Could not open $filename for writing"; endif; ?>