note 35016 added to function.fwrite
| From: | cwytch at cox dot net | Date: | Fri, 15 Aug 2003 16:48:30 +0000 |
| Subject: | note 35016 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54220@lists.php.net to get a copy of this message | ||
i used this im makeing a messageboard by text with this
what i want to do is insted of it printing Add this to the file
i want it to post what ever the person has typed how would i do that here is the code
<?php
$filename = 'messageboard.txt';
$somecontent = "<br> Add this to the file\n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
print "The file $filename is not writable";
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.fwrite.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35016
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35016&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35016&report=yes