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

- All id attributes are now xml:id - Add docbook namespace to all root elements - Replace <ulink /> with <link xlink:href /> - Minor markup fixes here and there git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
193 lines
4.7 KiB
XML
193 lines
4.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.4 $ -->
|
|
<refentry xml:id="function.ziparchive-open" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>ZipArchive::open</refname>
|
|
<refpurpose>Open a ZIP file archive</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>ZipArchive::open</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Opens a new zip archive for reading, writing or modifying.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The file name of the ZIP archive to open.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The mode to use to open the archive.
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::OVERWRITE</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::CREATE</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::EXCL</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::CHECKCONS</constant>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>Error codes</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Returns &true; on success or the error code.
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_EXISTS</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_INCONS</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_INVAL</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_MEMORY</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_NOENT</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_NOZIP</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_OPEN</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_READ</constant>
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_SEEK</constant>
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
This example opens a ZIP file archive, reads each file in the
|
|
archive and prints out its contents. The
|
|
<filename>test2.zip</filename> archive used in this example is
|
|
one of the test archives in the ZZIPlib source distribution.
|
|
</para>
|
|
<example>
|
|
<title>Open and extract</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$zip = new ZipArchive;
|
|
$res = $zip->open('test.zip')
|
|
if ($res === TRUE) {
|
|
echo 'ok';
|
|
$zip->extractTo('test');
|
|
$zip->close();
|
|
} else {
|
|
echo 'failed, code:' . $res;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Create an archive</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$zip = new ZipArchive;
|
|
$res = $zip->open('test.zip', ZipArchive::CREATE);
|
|
if ($res === TRUE) {
|
|
$zip->addFromString('test.txt', 'file content goes here');
|
|
$zip->addFile('data.txt', 'entryname.txt');
|
|
$zip->close();
|
|
echo 'ok';
|
|
} else {
|
|
echo 'failed';
|
|
}
|
|
?>
|
|
]]>
|
|
</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
|
|
-->
|