note 40085 deleted from function.fwrite by irchtml
| From: | irchtml@php.net | Date: | Mon, 23 Feb 2004 07:52:57 +0000 |
| Subject: | note 40085 deleted from function.fwrite by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65565@lists.php.net to get a copy of this message | ||
Note Submitter: c32@c32.net
----
This is correction:
This a correction for the second example ,
because $filename is not a variable, so the right way is this (i test it):
<?php
$file = "example.txt";
if (!$handle = fopen($file, 'a')) {
print "Cannot open file ($file)";
exit;
}
$somecontent = "Hello";
if(is_writable($file)){
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($file)";
exit;
}
} else {
chmod ($file , 0777) or die ("I found out you couldn't write to the file so I tried to
chmod it but it didn't work");
echo "Please refresh the page";
}
?>
so this script will write it in the example.txt, the word Hello.
C32/.