Writing data to a file : fwrite « File Directory « PHP






Writing data to a file

 
<?php
$fh = fopen('/tmp/cookie-data','w')      or die("can't open file");
if (-1 == fwrite($fh,$_COOKIE['flavor'])) { die("can't write data"); }
fclose($fh)                              or die("can't close file");
?>
  
  








Related examples in the same category

1.A simple access counter
2.Appending to a file
3.fwrite() function writes string to the file.
4.fwrite.php
5.Using file-related error information
6.Storing user information in a text file