#51006 [NEW]: bug in fwrite section of the manual

From: Date: Wed, 10 Feb 2010 23:31:08 +0000
Subject: #51006 [NEW]: bug in fwrite section of the manual
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3863@lists.php.net to get a copy of this message
From: php at mi dot cx Operating system: all PHP version: Irrelevant PHP Bug Type: Documentation problem Bug description: bug in fwrite section of the manual 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 bug report at http://bugs.php.net/?id=51006&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51006&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51006&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51006&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51006&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51006&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51006&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51006&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51006&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51006&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51006&r=support Expected behavior: http://bugs.php.net/fix.php?id=51006&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51006&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51006&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51006&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51006&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51006&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51006&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51006&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51006&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51006&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51006&r=mysqlcfg

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