add php://memory and php://temp

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@220363 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Nuno Lopes 2006-09-22 17:05:11 +00:00
parent d157ed8033
commit f64d0e1f17

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.64 $ -->
<!-- $Revision: 1.65 $ -->
<appendix id="wrappers">
<title>List of Supported Protocols/Wrappers</title>
<para>
@ -603,11 +603,6 @@ X-MyCustomHeader: Foo
<section id="wrappers.php">
<title>PHP input/output streams</title>
<simpara>
PHP 3.0.13 and up, <filename>php://output</filename>
and <filename>php://input</filename> since PHP 4.3.0,
<filename>php://filter</filename> since PHP 5.0.0.
</simpara>
<itemizedlist>
<listitem><simpara><filename>php://stdin</filename></simpara></listitem>
@ -615,7 +610,9 @@ X-MyCustomHeader: Foo
<listitem><simpara><filename>php://stderr</filename></simpara></listitem>
<listitem><simpara><filename>php://output</filename></simpara></listitem>
<listitem><simpara><filename>php://input</filename></simpara></listitem>
<listitem><simpara><filename>php://filter</filename></simpara></listitem>
<listitem><simpara><filename>php://filter</filename> (available since PHP 5.0.0)</simpara></listitem>
<listitem><simpara><filename>php://memory</filename> (available since PHP 5.1.0)</simpara></listitem>
<listitem><simpara><filename>php://temp</filename> (available since PHP 5.1.0)</simpara></listitem>
</itemizedlist>
<simpara>
@ -730,6 +727,44 @@ file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello
</simpara>
</listitem>
</itemizedlist>
<simpara>
The <filename>php://memory</filename> wrapper stores the data in the
memory. <filename>php://temp</filename> behaves similarly, but uses a
temporary file for storing the data when a certain memory limit is reached
(the default is 2 MB).
</simpara>
<simpara>
The <filename>php://temp</filename> wrapper takes the following
'parameters' as parts of its 'path':
</simpara>
<itemizedlist>
<listitem>
<para>
<literal>/maxmemory:&lt;number of bytes&gt;</literal>
(<emphasis>optional</emphasis>). This parameter allows changing the
default value for the memory limit (when the data is moved to a temporary
file).
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$fiveMBs = 5 * 1024 * 1024;
$fp = fopen("php://temp/maxmemory:$fiveMBs", 'r+');
fputs($fp, "hello\n");
// read what we have written
rewind($fp);
echo stream_get_contents($fp);
?>
]]>
</programlisting>
</informalexample>
</para>
</listitem>
</itemizedlist>
<para>
<table>
<title>
@ -751,33 +786,45 @@ file_put_contents("php://filter/write=string.rot13/resource=example.txt","Hello
<row>
<entry>Allows Reading</entry>
<entry>
<literal>php://stdin</literal> and
<literal>php://input</literal> only.
<literal>php://stdin</literal>,
<literal>php://input</literal>,
<literal>php://memory</literal> and
<literal>php://temp</literal> only.
</entry>
</row>
<row>
<entry>Allows Writing</entry>
<entry>
<literal>php://stdout</literal>,
<literal>php://stderr</literal>, and
<literal>php://output</literal> only.
<literal>php://stderr</literal>,
<literal>php://output</literal>,
<literal>php://memory</literal> and
<literal>php://temp</literal> only.
</entry>
</row>
<row>
<entry>Allows Appending</entry>
<entry>
<literal>php://stdout</literal>,
<literal>php://stderr</literal>, and
<literal>php://output</literal> only. (Equivalent to writing)
<literal>php://stderr</literal>,
<literal>php://output</literal>,
<literal>php://memory</literal> and
<literal>php://temp</literal> only. (Equivalent to writing)
</entry>
</row>
<row>
<entry>Allows Simultaneous Reading and Writing</entry>
<entry>No. These wrappers are unidirectional.</entry>
<entry>
<literal>php://memory</literal> and
<literal>php://temp</literal> only.
</entry>
</row>
<row>
<entry>Supports <function>stat</function></entry>
<entry>No</entry>
<entry>
<literal>php://memory</literal> and
<literal>php://temp</literal> only.
</entry>
</row>
<row>
<entry>Supports <function>unlink</function></entry>