clarify that greedy read is for regular local files only.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@199380 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Wez Furlong 2005-10-27 20:31:18 +00:00
parent 6225d10323
commit 4c20c1c6a7

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.17 $ -->
<!-- $Revision: 1.18 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.25 -->
<refentry id="function.fread">
<refnamediv>
@ -16,7 +16,7 @@
<simpara>
<function>fread</function> reads up to
<parameter>length</parameter> bytes from the file pointer
referenced by <parameter>handle</parameter>. Reading stops when
referenced by <parameter>handle</parameter>. Reading stops when up to
<parameter>length</parameter> bytes have been read, EOF
(end of file) is reached, or (for network streams) when a
packet becomes available, whichever comes first.
@ -63,11 +63,12 @@ fclose($handle);
<warning>
<para>
When reading from network streams or pipes, such as those returned when
When reading from anything that is not a regular local file, such as
streams returned when
reading <link linkend="features.remote-files">remote files</link> or from
<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.
collect the data together in chunks as shown in the examples below.
</para>
</warning>
<para>
@ -75,6 +76,20 @@ fclose($handle);
<programlisting role="php">
<![CDATA[
<?php
// For PHP 5 and up
$handle = fopen("http://www.example.com/", "rb");
$contents = stream_get_contents($handle);
fclose($handle);
?>
]]>
</programlisting>
</informalexample>
</para>
<para>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$handle = fopen("http://www.example.com/", "rb");
$contents = '';
while (!feof($handle)) {