Fix example 3. Remove erroneous note.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@154524 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Sara Golemon 2004-03-24 20:39:40 +00:00
parent 3ee3100436
commit 9125bb167c

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<!-- $Revision: 1.16 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.25 -->
<refentry id="function.fread">
<refnamediv>
@ -62,7 +62,7 @@ fclose($handle);
<para>
When reading from network streams or pipes, such as those returned when
reading <link linkend="features.remote-files">remote files</link> or from
<function>popen</function> and <function>proc_open</function>, reading
<function>popen</function> and <function>fsockopen</function>, reading
will stop after a packet is available. This means that you should
collect the data together in chunks as shown in the example below.
</para>
@ -73,27 +73,16 @@ fclose($handle);
<![CDATA[
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = "";
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$contents .= $data;
} while (true);
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
?>
]]>
</programlisting>
</informalexample>
</para>
<note>
<para>
The example above has better performance than the traditional approach
using while(!<function>feof</function>), as we are saving the overhead
of a function call per iteration.
</para>
</note>
<note>
<para>
If you just want to get the contents of a file into a string, use