#51006 [Opn->Csd]: bug in fwrite section of the manual

From: Date: Tue, 16 Feb 2010 07:32:50 +0000
Subject: #51006 [Opn->Csd]: bug in fwrite section of the manual
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3896@lists.php.net to get a copy of this message
ID: 51006 Updated by: kalle@php.net Reported By: php at mi dot cx -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: all PHP Version: Irrelevant -Assigned To: +Assigned To: kalle New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. I agreed that the return value here seems odd, even though it might be intended to return false in case of a writing error. I changed it to return the value of $written. Previous Comments: ------------------------------------------------------------------------ [2010-02-16 07:32:04] svn@php.net Automatic comment from SVN on behalf of kalle Revision: http://svn.php.net/viewvc/?view=revision&revision=295141 Log: Fixed bug #51006 (bug in fwrite section of the manual) ------------------------------------------------------------------------ [2010-02-10 23:31:08] php at mi dot cx Description: ------------ I suspect that the demo fwrite_stream(..) example contains a tiny buglet... in: function fwrite_stream($fp, $string) { for ($written = 0; $written < strlen($string); $written += $fwrite) { $fwrite = fwrite($fp, substr($string, $written)); if (!$fwrite) { return $fwrite; } } return $written; } the snipet: if (!$fwrite) { return $fwrite; } should read: if (!$fwrite) { return $written; } Since if the write fails on the second iteration, it should return what has been written so far, not zero. Also, another improvement is probably: if ($fwrite===false) { return $fwritten; } But not strictly necessary in this instance because the loop wont be entered if there is nothing to be written. Chris Hale. Reproduce code: --------------- --- From manual page: function.fwrite --- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=51006&edit=1

« previous php.doc.bugs (#3896) next »