Files
archived-doc-pt-br/reference/bzip2/examples.xml
2026-01-25 15:17:29 +00:00

63 lines
1.4 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: 5fdeb11b137c94a6d25cbe98a2e14c00366197cf Maintainer: felipe Status: ready -->
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="bzip2.examples">
&reftitle.examples;
<simpara>
Este exemplo abre um arquivo temporário e escreve uma string de test
nele, e então mostra o conteúdo do arquivo.
</simpara>
<example>
<title>Um exemplo simples de bzip2</title>
<programlisting role="php">
<![CDATA[
<?php
$filename = "/tmp/testfile.bz2";
$str = "Este é um texto de teste.\n";
// abre o arquivo para escrita
$bz = bzopen($filename, "w");
// escreve string no arquivo
bzwrite($bz, $str);
// fecha o arquivo
bzclose($bz);
// abre o arquivo para leitura
$bz = bzopen($filename, "r");
// lê 10 caracteres
echo bzread($bz, 10);
// exibe até o final do arquivo (ou os próximos 1024 caracteres) e o fecha.
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
sgml-default-dtd-file:"~/.phpdoc/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
-->