php-doc-en/reference/phar/PharData/addFromString.xml
Daniel Egeberg 96c9d88bad Converted to utf-8
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
2010-03-28 22:10:10 +00:00

116 lines
2.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="phardata.addfromstring">
<refnamediv>
<refname>PharData::addFromString</refname>
<refpurpose>Add a file from the filesystem to the tar/zip archive</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>PharData::addFromString</methodname>
<methodparam><type>string</type><parameter>localname</parameter></methodparam>
<methodparam><type>string</type><parameter>contents</parameter></methodparam>
</methodsynopsis>
<para>
With this method, any string can be added to the tar/zip archive.
The file will be stored in the archive with <literal>localname</literal> as its
path. This method is similar to <function>ZipArchive::addFromString</function>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>localname</parameter></term>
<listitem>
<para>
Path that the file will be stored in the archive.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>contents</parameter></term>
<listitem>
<para>
The file contents to store
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
no return value, exception is thrown on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>PharData::addFromString</function> example</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();
// to add contents from a stream handle for large files, use offsetSet()
$c = fopen('/path/to/hugefile.bin');
$a['largefile.bin'] = $c;
fclose($c);
} catch (Exception $e) {
// handle errors here
}
?>
]]>
</programlisting>
</example>
</para>
</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
-->