<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/reserved.interfaces.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'class.traversable.php',
    1 => 'Traversable',
    2 => 'Traversable （遍历）接口',
  ),
  'up' => 
  array (
    0 => 'reserved.interfaces.php',
    1 => '预定义接口和类',
  ),
  'prev' => 
  array (
    0 => 'reserved.interfaces.php',
    1 => '预定义接口和类',
  ),
  'next' => 
  array (
    0 => 'class.iterator.php',
    1 => 'Iterator',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'language/predefined/traversable.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.traversable" class="reference">

 <h1 class="title"> <span class="interfacename"><a href="class.traversable.php" class="interfacename">Traversable</a></span> （遍历）接口</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5, PHP 7, PHP 8)</p>


  <div class="section" id="traversable.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    检测一个类是否可以使用 <a href="control-structures.foreach.php" class="link"><code class="literal">foreach</code></a> 进行遍历的接口。
   </p>
   <p class="para">
    无法被单独实现的基本抽象接口。相反，它必须由 <span class="interfacename"><a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a></span> 
    或 <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span> 接口实现。
   </p>
  </div>


  <div class="section" id="traversable.synopsis">
   <h2 class="title">接口摘要</h2>


   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="modifier">interface</span> <strong class="interfacename"><strong class="interfacename">Traversable</strong></strong> {</div>
   }</div>


   <p class="para">
    这个接口没有任何方法，它的作用仅仅是作为所有可遍历类的基本接口。
   </p>

  </div>

  <div class="section">
   <h2 class="title">更新日志</h2>
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.4.0</td>
       <td>
        <span class="interfacename"><strong class="interfacename">Traversable</strong></span> 接口现在可以由抽象类实现。继承的类必须实现
        <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span> 或 <span class="interfacename"><a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a></span>。
       </td>
      </tr>

     </tbody>
    
   </table>

  </div>

  <div class="section">
   <h2 class="title">注释</h2>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     实现此接口的内置类可以使用 <a href="control-structures.foreach.php" class="link"><code class="literal">foreach</code></a> 进行遍历而无需实现 <span class="interfacename"><a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a></span>
     或 <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span> 接口。
    </p>
   </p></blockquote>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     在 PHP 7.4.0 之前，这个内部引擎接口无法在 PHP 脚本中实现。必须改用 <span class="interfacename"><a href="class.iteratoraggregate.php" class="interfacename">IteratorAggregate</a></span>
     或 <span class="interfacename"><a href="class.iterator.php" class="interfacename">Iterator</a></span>。
    </p>
   </p></blockquote>
  </div>

 </div>

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