didou Sun Dec 14 18:06:29 2003 EDT
Modified files: /phpdoc/en/reference/bzip2/functions bzopen.xml bzread.xml Log: less noise in bzopen example and more in bzread see also feof for bzread some tags Index: phpdoc/en/reference/bzip2/functions/bzopen.xml diff -u phpdoc/en/reference/bzip2/functions/bzopen.xml:1.4 phpdoc/en/reference/bzip2/functions/bzopen.xml:1.5 --- phpdoc/en/reference/bzip2/functions/bzopen.xml:1.4 Mon Dec 8 08:52:41 2003 +++ phpdoc/en/reference/bzip2/functions/bzopen.xml Sun Dec 14 18:06:28 2003 @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/bzip2.xml, last change in rev 1.1 --> <refentry id="function.bzopen"> <refnamediv> <refname>bzopen</refname> - <refpurpose>Open a bzip2 compressed file</refpurpose> + <refpurpose>Opens a bzip2 compressed file</refpurpose> </refnamediv> <refsect1> <title>Description</title> @@ -14,13 +14,13 @@ <methodparam><type>string</type><parameter>mode</parameter></methodparam> </methodsynopsis> <para> - Opens a bzip2 (.bz2) file for reading or writing. + <function>bzopen</function> opens a bzip2 (.bz2) file for reading or writing. <parameter>filename</parameter> is the name of the file to open. <parameter>mode</parameter> is similar to the <function>fopen</function> function (`r' for read, `w' for write, etc.). </para> <para> - If the open fails, the function returns &false;, otherwise it + If the open fails, <function>bzopen</function> returns &false;, otherwise it returns a pointer to the newly opened file. </para> <para> @@ -29,17 +29,12 @@ <programlisting role="php"> <![CDATA[ <?php -$bz = bzopen("/tmp/foo.bz2", "r"); -$decompressed_file = ''; -while (!feof($bz)) { - $decompressed_file .= bzread($bz, 4096); -} +$file = "/tmp/foo.bz2"; +$bz = bzopen($file, "r") or die("Couldn't open $file for reading"); + bzclose($bz); -echo "The contents of /tmp/foo.bz2 are: "; -echo "\n<br>\n"; -echo $decompressed_file; ?> ]]> </programlisting> Index: phpdoc/en/reference/bzip2/functions/bzread.xml diff -u phpdoc/en/reference/bzip2/functions/bzread.xml:1.3 phpdoc/en/reference/bzip2/functions/bzread.xml:1.4 --- phpdoc/en/reference/bzip2/functions/bzread.xml:1.3 Mon Dec 8 08:52:41 2003 +++ phpdoc/en/reference/bzip2/functions/bzread.xml Sun Dec 14 18:06:28 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <!-- splitted from ./en/functions/bzip2.xml, last change in rev 1.1 --> <refentry id="function.bzread"> <refnamediv> @@ -29,16 +29,28 @@ <programlisting role="php"> <![CDATA[ <?php -$bz = bzopen("/tmp/foo.bz2", "r"); -$str = bzread($bz, 2048); -echo $str; + +$file = "/tmp/foo.bz2"; +$bz = bzopen($file", "r") or die("Couldn't open $file"); + +$decompressed_file = ''; +while (!feof($bz)) { + $decompressed_file .= bzread($bz, 4096); +} +bzclose($bz); + +echo "The contents of /tmp/foo.bz2 are: <br />\n"; +echo $decompressed_file; + ?> ]]> </programlisting> </example> </para> <para> - See also <function>bzwrite</function> and <function>bzopen</function>. + See also <function>bzwrite</function>, + <function>feof</function>, and + <function>bzopen</function>. </para> </refsect1> </refentry>