fwrite() function writes string to the file. : fwrite « File Directory « PHP






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;
?>
  
  








Related examples in the same category

1.A simple access counter
2.Appending to a file
3.fwrite.php
4.Using file-related error information
5.Writing data to a file
6.Storing user information in a text file