<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.phardata.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'phardata.extractto.php',
    1 => 'PharData::extractTo',
    2 => 'Extract the contents of a tar/zip archive to a directory',
  ),
  'up' => 
  array (
    0 => 'class.phardata.php',
    1 => 'PharData',
  ),
  'prev' => 
  array (
    0 => 'phardata.destruct.php',
    1 => 'PharData::__destruct',
  ),
  'next' => 
  array (
    0 => 'phardata.iswritable.php',
    1 => 'PharData::isWritable',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/PharData/extractTo.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phardata.extractto" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PharData::extractTo</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">PharData::extractTo</span> &mdash; <span class="dc-title">Extract the contents of a tar/zip archive to a directory</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phardata.extractto-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>PharData::extractTo</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$files</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$overwrite</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>


  <p class="para rdfs-comment">
   Extract all files within a tar/zip archive to disk.  Extracted files and directories preserve
   permissions as stored in the archive.  The optional parameters allow optional control over
   which files are extracted, and whether existing files on disk can be overwritten.
   The second parameter <code class="literal">files</code> can be either the name of a file or
   directory to extract, or an array of names of files and directories to extract.  By
   default, this method will not overwrite existing files, the third parameter can be
   set to true to enable overwriting of files.
   This method is similar to <span class="function"><a href="ziparchive.extractto.php" class="function">ZipArchive::extractTo()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phardata.extractto-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       Path to extract the given <code class="literal">files</code> to
      </p>
     </dd>
    
    
     <dt><code class="parameter">files</code></dt>
     <dd>
      <p class="para">
       The name of a file or directory to extract, or an array of files/directories to extract
      </p>
     </dd>
    
    
     <dt><code class="parameter">overwrite</code></dt>
     <dd>
      <p class="para">
       Set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> to enable overwriting existing files
      </p>
     </dd>
    
   </dl>
  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phardata.extractto-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> on success, but it is better to check for thrown exception,
   and assume success if none is thrown.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phardata.extractto-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
   Throws <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> if errors occur while flushing
   changes to disk.
  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-phardata.extractto-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 A <span class="function"><strong>PharData::extractTo()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try {<br />    </span><span style="color: #0000BB">$phar </span><span style="color: #007700">= new </span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'myphar.tar'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/full/path'</span><span style="color: #007700">); </span><span style="color: #FF8000">// extract all files<br />    </span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/another/path'</span><span style="color: #007700">, </span><span style="color: #DD0000">'file.txt'</span><span style="color: #007700">); </span><span style="color: #FF8000">// extract only file.txt<br />    </span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/this/path'</span><span style="color: #007700">,<br />        array(</span><span style="color: #DD0000">'file1.txt'</span><span style="color: #007700">, </span><span style="color: #DD0000">'file2.txt'</span><span style="color: #007700">)); </span><span style="color: #FF8000">// extract 2 files only<br />    </span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/third/path'</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">); </span><span style="color: #FF8000">// extract all files, and overwrite<br /></span><span style="color: #007700">} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// handle errors<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-phardata.extractto-notes">
  <h3 class="title">Note</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <p class="para">Windows NTFS file systems
do not support some characters in filenames, namely <code class="literal">&lt;|&gt;*?&quot;:</code>. Filenames with a trailing dot
are not supported either. Contrary to some extraction tools, this method does not replace these characters with
an underscore, but instead fails to extract such files.</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-phardata.extractto-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.extractto.php" class="function" rel="rdfs-seeAlso">Phar::extractTo()</a> - Extract the contents of a phar archive to a directory</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>