Network stream

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@281274 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2009-05-28 09:00:55 +00:00
parent 507ba25d7d
commit 460e567981

View file

@ -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>
@ -71,6 +71,28 @@
<refsect1 role="notes">
&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
@ -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