<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionclass.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'reflectionclass.getreflectionconstants.php',
    1 => 'ReflectionClass::getReflectionConstants',
    2 => 'クラス定数を取得する',
  ),
  'up' => 
  array (
    0 => 'class.reflectionclass.php',
    1 => 'ReflectionClass',
  ),
  'prev' => 
  array (
    0 => 'reflectionclass.getreflectionconstant.php',
    1 => 'ReflectionClass::getReflectionConstant',
  ),
  'next' => 
  array (
    0 => 'reflectionclass.getshortname.php',
    1 => 'ReflectionClass::getShortName',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/reflection/reflectionclass/getreflectionconstants.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionclass.getreflectionconstants" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::getReflectionConstants</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.1.0, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::getReflectionConstants</span> &mdash; <span class="dc-title">クラス定数を取得する</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.getreflectionconstants-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::getReflectionConstants</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$filter</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   リフレクションされた定数を取得します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.getreflectionconstants-parameters">
  <h3 class="title">パラメータ</h3>
  <dl>
   
    <dt><code class="parameter">filter</code></dt>
    <dd>
     <p class="para">
      オプションのフィルタで、取得したい定数の型を絞り込みます。
      <a href="class.reflectionclassconstant.php#reflectionclassconstant.constants.modifiers" class="link">ReflectionClassConstant の定数</a>
      で設定し、デフォルトではすべての定数を取得します。
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.getreflectionconstants-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   <span class="classname"><a href="class.reflectionclassconstant.php" class="classname">ReflectionClassConstant</a></span> の配列を返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-reflectionclass.getreflectionconstants-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">filter</code> が追加されました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.getreflectionconstants-examples">
  <h3 class="title">例</h3>
  <div class="example" id="reflectionclass.getreflectionconstants.example">
   <p><strong>例1 基本的な <span class="function"><strong>ReflectionClass::getReflectionConstants()</strong></span> の例</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">Foo </span><span style="color: #007700">{<br />    public    const </span><span style="color: #0000BB">FOO  </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />    protected const </span><span style="color: #0000BB">BAR  </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br />    private   const </span><span style="color: #0000BB">BAZ  </span><span style="color: #007700">= </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$foo </span><span style="color: #007700">= new </span><span style="color: #0000BB">Foo</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$reflect </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #0000BB">$foo</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$consts  </span><span style="color: #007700">= </span><span style="color: #0000BB">$reflect</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getReflectionConstants</span><span style="color: #007700">();<br /><br />foreach (</span><span style="color: #0000BB">$consts </span><span style="color: #007700">as </span><span style="color: #0000BB">$const</span><span style="color: #007700">) {<br />    print </span><span style="color: #0000BB">$const</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">() . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$consts</span><span style="color: #007700">);<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="annotation-interactive examplescode"><pre class="examplescode">FOO
BAR
BAZ
array(3) {
  [0]=&gt;
  object(ReflectionClassConstant)#3 (2) {
    [&quot;name&quot;]=&gt;
    string(3) &quot;FOO&quot;
    [&quot;class&quot;]=&gt;
    string(3) &quot;Foo&quot;
  }
  [1]=&gt;
  object(ReflectionClassConstant)#4 (2) {
    [&quot;name&quot;]=&gt;
    string(3) &quot;BAR&quot;
    [&quot;class&quot;]=&gt;
    string(3) &quot;Foo&quot;
  }
  [2]=&gt;
  object(ReflectionClassConstant)#5 (2) {
    [&quot;name&quot;]=&gt;
    string(3) &quot;BAZ&quot;
    [&quot;class&quot;]=&gt;
    string(3) &quot;Foo&quot;
  }
}</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.getreflectionconstants-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionclass.getreflectionconstant.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::getReflectionConstant()</a> - クラス定数の ReflectionClassConstant を取得する</span></li>
    <li><span class="classname"><a href="class.reflectionclassconstant.php" class="classname">ReflectionClassConstant</a></span></li>
   </ul>
  </p>
 </div>


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