Re: Append a line to a Text File
| From: | Miguel Cruz | Date: | Mon, 29 Apr 2002 02:56:14 +0000 |
| Subject: | Re: Append a line to a Text File | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95060@lists.php.net to get a copy of this message | ||
On Sun, 28 Apr 2002, Rodrigo wrote:
> I still need to know how to do it, since the "a+" or the "a" give me
> problems...
What kind of problems? Do you get an error message that you can paste into
a message for us to see? Does the file get corrupted in some specific way
that you can describe? Does your computer start on fire?
> I need to be able to add a line at the end of a text file thru sending
> the information (and by this I mean the e-mail to be writen) thru a
> form, and this new information should be added to the file at the end of
> it without overwriting it.
>
> PS: If possible send a code for instruction. ;)
<?
$file_pointer = fopen('/tmp/myfile', 'a') || exit;
$string_to_write = date('j-M-Y H:i:s') . "\n";
fwrite($file_pointer, $string_to_write);
fclose($file_pointer);
?>
miguel