📄 function.ziparchive-extractto.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Extract the archive contents</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ziparchive-deletename.html">ZipArchive::deleteName</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ziparchive-getarchivecomment.html">ZipArchive::getArchiveComment</a></div> <div class="up"><a href="ref.zip.html">Zip Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.ziparchive-extractto" class="refentry"> <div class="refnamediv"> <h1 class="refname">ZipArchive::extractTo</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">ZipArchive::extractTo</span> — <span class="dc-title">Extract the archive contents</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b><b>ZipArchive::extractTo</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$destination</tt></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$entries</tt></span> ] )</div> <p class="para rdfs-comment"> Extract the complete archive or the given files to the specified destination. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">destination</tt></i></span> <dd> <p class="para"> Location where to extract the files. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">entries</tt></i></span> <dd> <p class="para"> The entries to extract. It accepts either a single entry name or an array of names. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> This example opens a ZIP file archive, reads each file in the archive and prints out its contents. The <var class="filename">test2.zip</var> archive used in this example is one of the test archives in the ZZIPlib source distribution. </p> <div class="example"> <p><b>Example #1 Extract all entries</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$zip </span><span style="color: #007700">= new </span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">;<br />if (</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">'test.zip'</span><span style="color: #007700">) === </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/my/destination/dir/'</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /> echo </span><span style="color: #DD0000">'ok'</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">'failed'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> <div class="example"> <p><b>Example #2 Extract only two entries</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$zip </span><span style="color: #007700">= new </span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">'test_im.zip'</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">$res </span><span style="color: #007700">=== </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">extractTo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/my/destination/dir/'</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'pear_item.gif'</span><span style="color: #007700">, </span><span style="color: #DD0000">'testfromfile.php'</span><span style="color: #007700">));<br /> </span><span style="color: #0000BB">$zip</span><span style="color: #007700">-></span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /> echo </span><span style="color: #DD0000">'ok'</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">'failed'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ziparchive-deletename.html">ZipArchive::deleteName</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ziparchive-getarchivecomment.html">ZipArchive::getArchiveComment</a></div> <div class="up"><a href="ref.zip.html">Zip Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -