2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 06:35:26 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-12-11 06:51:54 +00:00
|
|
|
|
|
|
|
<chapter xml:id="bzip2.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
|
|
|
This example opens a temporary file and writes a test string to
|
|
|
|
it, then prints out the contents of the file.
|
|
|
|
</para>
|
|
|
|
<example>
|
|
|
|
<title>Small bzip2 Example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$filename = "/tmp/testfile.bz2";
|
|
|
|
$str = "This is a test string.\n";
|
|
|
|
|
|
|
|
// open file for writing
|
|
|
|
$bz = bzopen($filename, "w");
|
|
|
|
|
|
|
|
// write string to file
|
|
|
|
bzwrite($bz, $str);
|
|
|
|
|
|
|
|
// close file
|
|
|
|
bzclose($bz);
|
|
|
|
|
|
|
|
// open file for reading
|
|
|
|
$bz = bzopen($filename, "r");
|
|
|
|
|
|
|
|
// read 10 characters
|
|
|
|
echo bzread($bz, 10);
|
|
|
|
|
|
|
|
// output until end of the file (or the next 1024 char) and close it.
|
|
|
|
echo bzread($bz);
|
|
|
|
|
|
|
|
bzclose($bz);
|
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</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
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2007-12-11 06:51:54 +00:00
|
|
|
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
|
|
|
|
-->
|
|
|
|
|