<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.phar.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'phar.count.php',
    1 => 'Phar::count',
    2 => 'Returns the number of entries (files) in the Phar archive',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.copy.php',
    1 => 'Phar::copy',
  ),
  'next' => 
  array (
    0 => 'phar.createdefaultstub.php',
    1 => 'Phar::createDefaultStub',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/Phar/count.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::count</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Phar::count</span> &mdash; <span class="dc-title">Returns the number of entries (files) in the Phar archive</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-phar.count-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Phar::count</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="array.constants.php#constant.count-normal">COUNT_NORMAL</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>


  <p class="para rdfs-comment">
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-phar.count-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">mode</code></dt>
    <dd>
     <p class="para">
      <code class="parameter">mode</code> is an integer value specifying the counting mode to be used.
      By default, it is set to <strong><code><a href="array.constants.php#constant.count-normal">COUNT_NORMAL</a></code></strong>,
      which counts only the number of items in the archive that have not been deleted or hidden.
      When set to <strong><code><a href="array.constants.php#constant.count-recursive">COUNT_RECURSIVE</a></code></strong>, it counts all items in the archive,
      including those that have been deleted or hidden.
     </p>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-phar.count-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The number of files contained within this phar, or <code class="literal">0</code> (the number zero)
   if none.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phar.count-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 A <span class="function"><strong>Phar::count()</strong></span> example</strong></p>
    <div class="example-contents"><p>
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// make sure it doesn't exist<br /></span><span style="color: #007700">@</span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #DD0000">'brandnewphar.phar'</span><span style="color: #007700">);<br />try {<br />    </span><span style="color: #0000BB">$p </span><span style="color: #007700">= new </span><span style="color: #0000BB">Phar</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">) . </span><span style="color: #DD0000">'/brandnewphar.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'brandnewphar.phar'</span><span style="color: #007700">);<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'Could not create phar:'</span><span style="color: #007700">, </span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br />echo </span><span style="color: #DD0000">'The new phar has ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">() . </span><span style="color: #DD0000">" entries\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'file.txt'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'hi'</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">'The new phar has ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">() . </span><span style="color: #DD0000">" entries\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">The new phar has 0 entries
The new phar has 1 entries</pre>
</div>
    </div>
   </div>
  </p>
 </div>


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