<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'reflectionclass.hasconstant.php',
    1 => 'ReflectionClass::hasConstant',
    2 => '检查常量是否已经定义',
  ),
  'up' => 
  array (
    0 => 'class.reflectionclass.php',
    1 => 'ReflectionClass',
  ),
  'prev' => 
  array (
    0 => 'reflectionclass.gettraits.php',
    1 => 'ReflectionClass::getTraits',
  ),
  'next' => 
  array (
    0 => 'reflectionclass.hasmethod.php',
    1 => 'ReflectionClass::hasMethod',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/reflection/reflectionclass/hasconstant.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionclass.hasconstant" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionClass::hasConstant</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionClass::hasConstant</span> &mdash; <span class="dc-title">检查常量是否已经定义</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionclass.hasconstant-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionClass::hasConstant</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$name</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   检查类中是否已经定义了指定的常量。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionclass.hasconstant-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">name</code></dt>
     <dd>
      <p class="para">
       要被检查的常量名称。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionclass.hasconstant-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果已定义返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>，否则返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionclass.hasconstant-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionClass::hasConstant()</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 />    const </span><span style="color: #0000BB">c1 </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$class </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionClass</span><span style="color: #007700">(</span><span style="color: #DD0000">"Foo"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hasConstant</span><span style="color: #007700">(</span><span style="color: #DD0000">"c1"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hasConstant</span><span style="color: #007700">(</span><span style="color: #DD0000">"c2"</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="annotation-interactive examplescode"><pre class="examplescode">bool(true)
bool(false)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionclass.hasconstant-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionclass.hasmethod.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::hasMethod()</a> - 检查方法是否已定义</span></li>
    <li><span class="methodname"><a href="reflectionclass.hasproperty.php" class="methodname" rel="rdfs-seeAlso">ReflectionClass::hasProperty()</a> - 检查属性是否已定义</span></li>
   </ul>
  </p>
 </div>


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