Files
php-doc-ru/reference/phar/PharData/construct.xml
Sergey Panteleev 6d43fd64d7 Исправление форматирования
[skip-spellcheck]
[skip-lint]
2022-12-27 03:42:36 +03:00

119 lines
4.0 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: f03806fcd8fe03a0501bd40b6e3939ff6589a1d2 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="phardata.construct">
<refnamediv>
<refname>PharData::__construct</refname>
<refpurpose>Конструктор объекта PharData</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<constructorsynopsis role="PharData">
<modifier>public</modifier> <methodname>PharData::__construct</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS</initializer></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>alias</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>format</parameter><initializer>0</initializer></methodparam>
</constructorsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
Путь либо к существующему tar/zip-архиву, либо к вновь создаваемому
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
Флаги для передачи родительскому классу <classname>Phar</classname>
<classname>RecursiveDirectoryIterator</classname>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>alias</parameter></term>
<listitem>
<para>
Псевдоним, который необходимо назначить phar-архиву для использования в
потоковых обёртках.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>format</parameter></term>
<listitem>
<para>
Одна из
<link linkend="phar.constants.fileformat">констант формата файлов</link>
доступная для класса <classname>Phar</classname>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Выбрасывает исключение <classname>BadMethodCallException</classname>, если вызван дважды;
Выбрасывает исключение <classname>UnexpectedValueException</classname>, если Phar-архив невозможно открыть.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>PharData::__construct</function></title>
<para>
<programlisting role="php">
<![CDATA[
<?php
try {
$p = new PharData('/path/to/my.tar', Phar::CURRENT_AS_FILEINFO | Phar::KEY_AS_FILENAME);
} catch (UnexpectedValueException $e) {
die('Не удалось открыть my.tar');
} catch (BadMethodCallException $e) {
echo 'Технически, это никогда не произойдёт';
}
echo file_get_contents('phar:///path/to/my.tar/example.txt');
?>
]]>
</programlisting>
</para>
</example>
</para>
</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
-->