mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 06:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322115 c90b9560-bf6c-de11-be94-00142212c4b1
214 lines
4.9 KiB
XML
214 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="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>
|
|
<para>
|
|
File already exists.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_INCONS</constant>
|
|
</para>
|
|
<para>
|
|
Zip archive inconsistent.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_INVAL</constant>
|
|
</para>
|
|
<para>
|
|
Invalid argument.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_MEMORY</constant>
|
|
</para>
|
|
<para>
|
|
Malloc failure.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_NOENT</constant>
|
|
</para>
|
|
<para>
|
|
No such file.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_NOZIP</constant>
|
|
</para>
|
|
<para>
|
|
Not a zip archive.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_OPEN</constant>
|
|
</para>
|
|
<para>
|
|
Can't open file.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_READ</constant>
|
|
</para>
|
|
<para>
|
|
Read error.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<constant>ZIPARCHIVE::ER_SEEK</constant>
|
|
</para>
|
|
<para>
|
|
Seek error.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<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:"~/.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
|
|
-->
|