note 83359 added to function.fwrite
| From: | kontakt at bmservices dot de | Date: | Thu, 22 May 2008 11:03:03 +0000 |
| Subject: | note 83359 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139608@lists.php.net to get a copy of this message | ||
Checking if fwrite failed will not work in that way:
if (!fwrite($fH, $myText)) echo "Write error";
because fwrite return the number of bytes written or FALSE in case of an error.
So: if $myText is an empty string, fwrite will return 0, which is interpreted here as
"FALSE", although the writing out of the string is ok.
So you should check in that way:
if (@fwrite($fH, $myText)===FALSE) echo "Write error";
Regards from Berlin, Gérôme
----
Server IP: 217.160.72.57
Probable Submitter: 62.145.19.66
----
Manual Page -- http://www.php.net/manual/en/function.fwrite.php
Edit -- https://master.php.net/note/edit/83359
Del: integrated -- https://master.php.net/note/delete/83359/integrated
Del: useless -- https://master.php.net/note/delete/83359/useless
Del: bad code -- https://master.php.net/note/delete/83359/bad+code
Del: spam -- https://master.php.net/note/delete/83359/spam
Del: non-english -- https://master.php.net/note/delete/83359/non-english
Del: in docs -- https://master.php.net/note/delete/83359/in+docs
Del: other reasons-- https://master.php.net/note/delete/83359
Reject -- https://master.php.net/note/reject/83359
Search -- https://master.php.net/manage/user-notes.php