1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-24 07:42:22 +01:00
Files
archived-doc-ru/reference/phar/PharData/addFromString.xml
2023-05-14 13:00:50 +03:00

122 lines
3.5 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: 88773698060b9bb3e9900bbd7cb8a3da588f1288 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="phardata.addfromstring" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>PharData::addFromString</refname>
<refpurpose>Добавляет файл из строки в архив tar/zip</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="PharData">
<modifier>public</modifier> <type>void</type><methodname>PharData::addFromString</methodname>
<methodparam><type>string</type><parameter>localName</parameter></methodparam>
<methodparam><type>string</type><parameter>contents</parameter></methodparam>
</methodsynopsis>
<para>
Этот метод позволяет создать внутри архива файл с заданным текстом.
Файл будет сохранён по пути <literal>localname</literal>. Этот метод
аналогичен <function>ZipArchive::addFromString</function>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>localName</parameter></term>
<listitem>
<para>
Путь создаваемого файла.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>contents</parameter></term>
<listitem>
<para>
Содержимое файла в виде строки
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Ничего не возвращает, в случае возникновения ошибки выбрасывает исключение.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>PharData::addFromString</function></title>
<programlisting role="php">
<![CDATA[
<?php
try {
$a = new PharData('/path/to/my.tar');
$a->addFromString('path/to/file.txt', 'my simple file');
$b = $a['path/to/file.txt']->getContent();
// Для добавления содержимого через потоковую обёртку для больших файлов, используйте offsetSet()
$c = fopen('/path/to/hugefile.bin');
$a['largefile.bin'] = $c;
fclose($c);
} catch (Exception $e) {
// обработка ошибок
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&phardata.note.performance;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>PharData::offsetSet</function></member>
<member><function>Phar::addFromString</function></member>
<member><function>PharData::addFile</function></member>
<member><function>PharData::addEmptyDir</function></member>
</simplelist>
</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
-->