commit for Brian Moon: clarified set_file_buffer documentation, added example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@31597 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Beckham 2000-08-31 14:16:36 +00:00
parent 575ece7ca1
commit 5fc9e137b0

View file

@ -1531,22 +1531,39 @@ luigi florist it
</funcprototype>
</funcsynopsis>
<simpara>
<function>set_file_buffer</function> sets the buffering for write
operations on the given filepointer <parameter>fp</parameter> to
<parameter>buffer</parameter> bytes. If
<parameter>buffer</parameter> is 0 then write operations are
unbuffered.
Output using <function>fwrite</function> is normally buffered at
8K. This means that if there are two processess wanting to write
to the same output stream (a file), each is paused after 8K of
data to allow the other to write. <function>set_file_buffer</function>
sets the buffering for write operations on the given filepointer
<parameter>fp</parameter> to <parameter>buffer</parameter> bytes.
If <parameter>buffer</parameter> is 0 then write operations are
unbuffered. This ensures that all writes with
<function>fwrite</function> are completed before other processes
are allowed to write to that output stream.
</simpara>
<simpara>
The function returns 0 on success, or EOF if the request cannot
be honored.
</simpara>
<para>
The following example demonstrates how to use
<function>set_file_buffer</function> to create an unbuffered stream.
<example>
<title><function>set_file_buffer</function> example</title>
<programlisting role="php">
$fp=fopen($file, "w");
if($fp){
set_file_buffer($fp, 0);
fputs($fp, $output);
fclose($fp);
}
</programlisting>
</example>
</para>
<simpara>
Note that the default for any fopen with calling set_file_buffer
is 8K.
</simpara>
<simpara>
See also <function>fopen</function>.
See also <function>fopen</function>, <function>fwrite</function>.
</simpara>
</refsect1>
</refentry>