|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-02-16 07:32 UTC] svn@php.net
[2010-02-16 07:32 UTC] kalle@php.net
[2020-02-07 06:09 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 03:00:02 2026 UTC |
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 ---