<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="phardata.addfromstring" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>PharData::addFromString</refname>
  <refpurpose>Add a file from a string to the tar/zip archive</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>
   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="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
-->
