note 46882 added to function.fwrite
| From: | chill at cuna dot org | Date: | Tue, 26 Oct 2004 22:32:40 +0000 |
| Subject: | note 46882 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79144@lists.php.net to get a copy of this message | ||
In PHP 4.3.7 fwrite returns 0 rather than false on failure.
The following example will output "SUCCESS: 0 bytes written" for existing file test.txt:
$fp = fopen("test.txt", "rw");
if (($bytes_written = fwrite($fp, "This is a test")) === false) {
echo "Unable to write to test.txt\n\n";
} else {
echo "SUCCESS: $bytes_written bytes written\n\n";
}
----
Manual Page -- http://www.php.net/manual/en/function.fwrite.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46882
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46882&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46882&report=yes
Search -- http://master.php.net/manage/user-notes.php