[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] cvs: phpdoc /en/reference/filesystem/functions fwrite.xml
From:       "Jakub Vrana" <vrana () php ! net>
Date:       2009-05-28 9:00:55
Message-ID: cvsvrana1243501255 () cvsserver
[Download RAW message or body]

vrana		Thu May 28 09:00:55 2009 UTC

  Modified files:              
    /phpdoc/en/reference/filesystem/functions	fwrite.xml 
  Log:
  Network stream
  
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/filesystem/functions/fwrite.xml?r1=1.18&r2=1.19&diff_format=u
                
Index: phpdoc/en/reference/filesystem/functions/fwrite.xml
diff -u phpdoc/en/reference/filesystem/functions/fwrite.xml:1.18 \
                phpdoc/en/reference/filesystem/functions/fwrite.xml:1.19
--- phpdoc/en/reference/filesystem/functions/fwrite.xml:1.18	Fri Apr 18 06:29:10 2008
+++ phpdoc/en/reference/filesystem/functions/fwrite.xml	Thu May 28 09:00:55 2009
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.18 $ -->
+<!-- $Revision: 1.19 $ -->
 <refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.fwrite">
  <refnamediv>
   <refname>fwrite</refname>
@@ -73,6 +73,28 @@
   &reftitle.notes;
   <note>
    <para>
+    Writing to a network stream may end before the whole string is written.
+    Return value of <function>fwrite</function> may be checked:
+    <programlisting role="php">
+<![CDATA[
+<?php
+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;
+}
+?>
+]]>
+    </programlisting>
+   </para>
+  </note>
+  
+  <note>
+   <para>
     On systems which differentiate between binary and text files
     (i.e. Windows) the file must be opened with 'b' included in
     <function>fopen</function> mode parameter.
@@ -92,9 +114,7 @@
   <note>
    <para>
     If writing twice to the file pointer, then the data will be appended to 
-    the end of the file content, meaning that the example below wouldn't work 
-    as expected:
-
+    the end of the file content:
         <programlisting role="php">
 <![CDATA[
 <?php



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic