mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 22:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322115 c90b9560-bf6c-de11-be94-00142212c4b1
119 lines
2.8 KiB
XML
119 lines
2.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="ziparchive.getstream" xmlns="http://docbook.org/ns/docbook">
|
|
<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&return.falseforfailure;.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title>Get the entry contents with <function>fread</function> 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 <function>fopen</function> 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:"~/.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
|
|
-->
|