⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phardata.buildfromdirectory.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Construct a tar/zip archive from the files within a directory.</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="phardata.addfromstring.html">PharData::addFromString</a></div> <div class="next" style="text-align: right; float: right;"><a href="phardata.buildfromiterator.html">PharData::buildFromIterator</a></div> <div class="up"><a href="class.PharData.html">PharData</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="phardata.buildfromdirectory" class="refentry"> <div class="refnamediv">  <h1 class="refname">PharData::buildFromDirectory</h1>  <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">PharData::buildFromDirectory</span> &mdash; <span class="dc-title">Construct a tar/zip archive from the files within a directory.</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">array</span> <span class="methodname"><b><a href="phar.buildfromdirectory.html" class="function">Phar::buildFromDirectory</a></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$base_dir</tt></span>   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$regex</tt></span>  ] )</div>  <p class="para rdfs-comment">   Populate a tar/zip archive from directory contents.  The optional second   parameter is a regular expression (pcre) that is used to exclude files.   Any filename that matches the regular expression will be included, all others will be   excluded.  For more fine-grained control, use <a href="phardata.buildfromiterator.html" class="function">PharData::buildFromIterator()</a>.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">base_dir</tt></i></span>     <dd>      <p class="para">       The full or relative path to the directory that contains all files       to add to the archive.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">regex</tt></i></span>     <dd>      <p class="para">       An optional pcre regular expression that is used to filter the       list of files.  Only file paths matching the regular expression       will be included in the archive.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   <a href="phar.buildfromdirectory.html" class="function">Phar::buildFromDirectory()</a> returns an associative array   mapping internal path of file to the full path of the file on the   filesystem.  </p> </div> <div class="refsect1 errors">  <h3 class="title">Errors/Exceptions</h3>  <p class="para">   This method throws <b class="classname">BadMethodCallException</b> when unable   to instantiate the internal directory iterators,   or a <a href="class.PharException.html" class="classname">PharException</a> if there were errors   saving the phar archive.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <div class="example">    <p><b>Example #1 A <b>PharData::buildFromDirectory()</b> example</b></p>  <div class="example-contents"><p>     </p></div>  <div class="example-contents"><p>   <div class="example-contents">    <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$phar&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'project.tar'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;add&nbsp;all&nbsp;files&nbsp;in&nbsp;the&nbsp;project<br /></span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buildFromDirectory</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/project'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$phar2&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'project2.zip'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;add&nbsp;all&nbsp;files&nbsp;in&nbsp;the&nbsp;project,&nbsp;only&nbsp;include&nbsp;php&nbsp;files<br /></span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buildFromDirectory</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/project'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'/\.php$/'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>   </div>  </p></div>  </div> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="phar.buildfromdirectory.html" class="function" rel="rdfs-seeAlso">Phar::buildFromDirectory()</a></li>    <li class="member"><a href="phardata.buildfromiterator.html" class="function" rel="rdfs-seeAlso">PharData::buildFromIterator()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phardata.addfromstring.html">PharData::addFromString</a></div> <div class="next" style="text-align: right; float: right;"><a href="phardata.buildfromiterator.html">PharData::buildFromIterator</a></div> <div class="up"><a href="class.PharData.html">PharData</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 + -