<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.countable.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'countable.count.php',
    1 => 'Countable::count',
    2 => 'オブジェクトの要素の数を数える',
  ),
  'up' => 
  array (
    0 => 'class.countable.php',
    1 => 'Countable',
  ),
  'prev' => 
  array (
    0 => 'class.countable.php',
    1 => 'Countable',
  ),
  'next' => 
  array (
    0 => 'class.arrayaccess.php',
    1 => 'ArrayAccess',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'language/predefined/countable/count.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="countable.count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Countable::count</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">Countable::count</span> &mdash; <span class="dc-title">オブジェクトの要素の数を数える</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-countable.count-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Countable::count</strong></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="simpara">
   このメソッドは、
   <span class="function"><a href="function.count.php" class="function">count()</a></span> 関数の
   <code class="parameter">value</code> パラメーターが
   <span class="classname"><a href="class.countable.php" class="classname">Countable</a></span> を実装している場合に実行されます。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-countable.count-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">この関数にはパラメータはありません。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-countable.count-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="simpara">
   数えたカスタムの結果を整数値として返します。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-countable.count-examples">
  <h3 class="title">例</h3>
  <div class="example" id="example-1">
   <p><strong>例1 <span class="function"><strong>Countable::count()</strong></span> の例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">Counter </span><span style="color: #007700">implements </span><span style="color: #0000BB">Countable<br /></span><span style="color: #007700">{<br />    private </span><span style="color: #0000BB">$count </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br />    public function </span><span style="color: #0000BB">count</span><span style="color: #007700">(): </span><span style="color: #0000BB">int<br />    </span><span style="color: #007700">{<br />        return ++</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">count</span><span style="color: #007700">;<br />    }<br />}<br /><br /></span><span style="color: #0000BB">$counter </span><span style="color: #007700">= new </span><span style="color: #0000BB">Counter</span><span style="color: #007700">;<br /><br />for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt; </span><span style="color: #0000BB">10</span><span style="color: #007700">; ++</span><span style="color: #0000BB">$i</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"I have been count()ed " </span><span style="color: #007700">. </span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$counter</span><span style="color: #007700">) . </span><span style="color: #DD0000">" times\n"</span><span style="color: #007700">;<br />}<br /><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">I have been count()ed 1 times
I have been count()ed 2 times
I have been count()ed 3 times
I have been count()ed 4 times
I have been count()ed 5 times
I have been count()ed 6 times
I have been count()ed 7 times
I have been count()ed 8 times
I have been count()ed 9 times
I have been count()ed 10 times</pre>
</div>
   </div>
  </div>
 </div>


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