php-doc-en/reference/zip/functions/ziparchive-getstream.xml
Pierre Joye 8adf44cc65 - add check for the return values ZipArchive::open, some examples
were not updated. Braindead--;


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218030 c90b9560-bf6c-de11-be94-00142212c4b1
2006-08-12 15:54:51 +00:00

119 lines
2.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<refentry id="function.ziparchive-getstream">
<refnamediv>
<refname>ZipArchive::getStream</refname>
<refpurpose>Get a file handler to the entry defined by its name (read only).</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>resource</type><methodname>ZipArchive::getStream</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
</methodsynopsis>
<para>
Get a file handler to the entry defined by its name. For now it only
supports read operations.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The name of the entry to use.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a file pointer (resource) on success or &false; on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Get the entry contents with fread and store it.</title>
<programlisting role="php">
<![CDATA[
<?php
$content = '';
$z = new ZipArchive();
if ($z->open('test.zip')) {
$fp = $z->getStream('test');
if(!$fp) exit("failed\n");
while (!feof($fp)) {
$contents .= fread($fp, 2);
}
fclose($fp);
file_put_contents('t',$contents);
echo "done.\n";
}
?>
]]>
</programlisting>
</example>
<example>
<title>Same as the previous example but with fopen and the zip
stream wrapper</title>
<programlisting role="php">
<![CDATA[
<?php
$fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
if (!$fp) {
exit("cannot open\n");
}
while (!feof($fp)) {
$contents .= fread($fp, 2);
echo "$contents\n";
}
fclose($fp);
echo "done.\n";
?>
]]>
</programlisting>
</example>
<example>
<title>Stream wrapper and image, can be used with the xml function
as well</title>
<programlisting role="php">
<![CDATA[
<?php
$im = imagecreatefromgif('zip://' . dirname(__FILE__) . '/test_im.zip#pear_item.gif');
imagepng($im, 'a.png');
?>
]]>
</programlisting>
</example>
</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
indent-tabs-mode:nil
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
-->