cvs: peardoc /en/package streams.xml /en/package/streams stream-var.xml /en/package/streams/stream-var example.xml intro.xml

From: Date: Tue, 23 Dec 2003 16:43:51 +0000
Subject: cvs: peardoc /en/package streams.xml /en/package/streams stream-var.xml /en/package/streams/stream-var example.xml intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2074@lists.php.net to get a copy of this message
schst Tue Dec 23 11:43:51 2003 EDT Added files: /peardoc/en/package streams.xml /peardoc/en/package/streams stream-var.xml /peardoc/en/package/streams/stream-var example.xml intro.xml Log: added Stream_Var documentation Index: peardoc/en/package/streams.xml +++ peardoc/en/package/streams.xml <!-- $Revision: 1.1 $ --> <chapter id="package.streams"> <title>Streams</title> <para> Provides Packages for streams API. For more information on stream wrappers see the <ulink url="http://www.php.net/manual/en/ref.stream.php">PHP Manual</ulink>. </para> &package.streams.stream-var; </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/streams/stream-var.xml +++ peardoc/en/package/streams/stream-var.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.streams.stream-var"> <title>Stream_Var</title> <para> Allows stream based access to variables. </para> &package.streams.stream-var.intro; &package.streams.stream-var.example; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/streams/stream-var/example.xml +++ peardoc/en/package/streams/stream-var/example.xml <!-- $Revision: 1.1 $ --> <refentry id="package.streams.stream-var.example"> <refnamediv> <refname>Example</refname> <refpurpose>Example for the usage of Stream_Var</refpurpose> </refnamediv> <refsect1 id="package.streams.stream-var.example.example1"> <title>Registering the wrapper</title> <simpara> The following example shows you how to register Stream_Var as a wrapper for the stream functions. </simpara> <example> <title>Registering Stream_Var</title> <programlisting role="php"> <![CDATA[require_once "Stream/Var.php"; stream_wrapper_register( "var", "Stream_Var" ); ]]> </programlisting> </example> </refsect1> <refsect1 id="package.streams.stream-var.example.example2"> <title>Accessing scalar variables</title> <simpara> The following example show you how to access scalar variables with <function>fopen</function>, <function>fread</function>, <function>frwite</function> and <function>fclose</function>. </simpara> <example> <title>Accessing scalar variables</title> <programlisting role="php"> <![CDATA[require_once "Stream/Var.php"; stream_wrapper_register( "var", "Stream_Var" ); $foo = "I really like tomatoes."; echo "Content of foo: $foo<br />"; $fp = fopen('var://GLOBALS/foo','r+'); $data = fread($fp, 9); echo "Read from stream: $data<br />"; fwrite($fp,"hate"); fclose($fp); echo "Content of foo: $foo<br />"; ]]> </programlisting> </example> </refsect1> <refsect1 id="package.streams.stream-var.example.example3"> <title>Accessing an array</title> <simpara> The following example shows how to use <function>opendir</function> to access an array. </simpara> <example> <title>Accessing scalar variables</title> <programlisting role="php"> <![CDATA[require_once "Stream/Var.php"; stream_wrapper_register( "var", "Stream_Var" ); $dirname = 'var://_SERVER'; $dir = opendir($dirname); echo "<strong>opening directory '$dirname'</strong><br><br>"; while ($entry = readdir($dir)) { echo "opening file $dirname/$entry<br />"; if (!$fp = @fopen($dirname."/".$entry,"r")) { echo "seems to be a directory<br /><br />"; continue; } echo "reading from $entry<br />"; while (!feof($fp)) { echo fread($fp, 16); } fclose($fp); echo "<br /><br />"; } closedir($dir); ]]> </programlisting> </example> </refsect1> <refsect1 id="package.streams.stream-var.example.more"> <title>More examples</title> <para> If you want to take a look at some more examples, just install the package and they will be installed in the docs directory. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/en/package/streams/stream-var/intro.xml +++ peardoc/en/package/streams/stream-var/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.streams.stream-var.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose>Introduction to Stream_Var</refpurpose> </refnamediv> <refsect1 id="package.streams.stream-var.intro.refsect1"> <title>Introduction to Stream_Var</title> <para> Stream_Var supplies a class that can be used as a wrapper for PHP&apos;' stream functions. This allows you to access variables with <function>fopen</function>, <function>fclose</function>, <function>fwrite</function>, <function>fread</function>, <function>opendir</function> and all other filesystem functions. </para> <para> You may use <function>stream_wrapper_register</function> to register Stream_Var as a wrapper. </para> <para> Scalar variables (strings, integers, floats) are treated as files, while arrays represent directories. </para> <para> Please see the <ulink url="http://www.php.net/manual/en/ref.stream.php">PHP Manual</ulink> or the <link linkend="package.streams.stream-var.example">example</link> for more information on how to register streams. </para> </refsect1> <refsect1 id="package.streams.stream-var.intro.refsect2"> <title>Usage scenario</title> <para> Stream_Var could be used in various scenarios. Imagine you are using a class that reads data from a file but you are creating the data on-the-fly and do not want to save the data before it can be processed by the class. </para> <para> This is, where Stream_Var can be used. Just register it as a wrapper for <function>fopen</function> and pass <parameter>var://GLOBAL/yourVar</parameter> as a parameter to the class. </para> <para> It will read from the variable as if it was a file. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.pear.doc (#2074) next »