<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.constants.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'language.constants.magic.php',
    1 => '魔术常量',
    2 => '魔术常量',
  ),
  'up' => 
  array (
    0 => 'language.constants.php',
    1 => '常量',
  ),
  'prev' => 
  array (
    0 => 'language.constants.predefined.php',
    1 => '预定义常量',
  ),
  'next' => 
  array (
    0 => 'language.expressions.php',
    1 => '表达式',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'language/constants.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="language.constants.magic" class="sect1">
  <h2 class="title">魔术常量</h2>
   <p class="para">
    一些魔术常量会根据使用位置而变化。例如 <strong><code><a href="language.constants.magic.php#constant.line">__LINE__</a></code></strong>
    的值取决于它在脚本中使用的行。所有这些“魔术”常量都在编译时解析，而常规常量则在运行时解析。这些特殊的常量不区分大小写，如下：
   </p>
   <p class="para">
    <table class="doctable table">
     <caption><strong>PHP 的魔术常量</strong></caption>
     
      <thead>
       <tr>
        <th>名字</th>
        <th>说明</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr id="constant.line">
        <td><strong><code><a href="language.constants.magic.php#constant.line">__LINE__</a></code></strong></td>
        <td>
         文件中的当前行号。
        </td>
       </tr>

       <tr id="constant.file">
        <td><strong><code><a href="language.constants.magic.php#constant.file">__FILE__</a></code></strong></td>
        <td>
         文件的完整路径和文件名。如果用在被包含文件中，则返回被包含的文件名。
        </td>
       </tr>

       <tr id="constant.dir">
        <td><strong><code><a href="language.constants.magic.php#constant.dir">__DIR__</a></code></strong></td>
        <td>
         文件所在的目录。如果用在被包括文件中，则返回被包括的文件所在的目录。它等价于
         <code class="literal">dirname(__FILE__)</code>。除非是根目录，否则目录中名不包括末尾的斜杠。
        </td>
       </tr>
       
       <tr id="constant.function">
        <td><strong><code><a href="language.constants.magic.php#constant.function">__FUNCTION__</a></code></strong></td>
        <td>
         当前函数的名称。匿名函数则为 <code class="literal">{closure}</code>。
        </td>
       </tr>

       <tr id="constant.class">
        <td><strong><code><a href="language.constants.magic.php#constant.class">__CLASS__</a></code></strong></td>
        <td>
         当前类的名称。类名包括其被声明的作用域（例如
         <code class="literal">Foo\Bar</code>）。当用在 trait 方法中时，<strong><code><a href="language.constants.magic.php#constant.class">__CLASS__</a></code></strong>
         是调用 trait 方法的类的名字。
        </td>
       </tr>

       <tr id="constant.trait">
        <td><strong><code><a href="language.constants.magic.php#constant.trait">__TRAIT__</a></code></strong></td>
        <td>
         Trait 的名字。Trait 名包括其被声明的作用域（例如
         <code class="literal">Foo\Bar</code>）。
        </td>
       </tr>

       <tr id="constant.method">
        <td><strong><code><a href="language.constants.magic.php#constant.method">__METHOD__</a></code></strong></td>
        <td>
         类的方法名。
        </td>
       </tr>

       <tr id="constant.property">
        <td><strong><code><a href="language.constants.magic.php#constant.property">__PROPERTY__</a></code></strong></td>
        <td>
         仅在<a href="language.oop5.property-hooks.php" class="link">属性挂钩</a>内有效。等同于属性的名称。
        </td>
       </tr>

       <tr id="constant.namespace">
        <td><strong><code><a href="language.constants.magic.php#constant.namespace">__NAMESPACE__</a></code></strong></td>
        <td>
         当前命名空间的名称。
        </td>
       </tr>

       <tr id="constant.coloncolonclass">
        <td><strong><code><span class="replaceable">ClassName</span>::class</code></strong></td>
        <td>
          完整的类名。
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>

   <div class="sect2">
   <h3 class="title">参见</h3>
    <p class="para">
     <ul class="simplelist">
      <li><a href="language.oop5.basic.php#language.oop5.basic.class.class" class="link">::class</a></li>
      <li><span class="function"><a href="function.get-class.php" class="function">get_class()</a></span></li>
      <li><span class="function"><a href="function.get-object-vars.php" class="function">get_object_vars()</a></span></li>
      <li><span class="function"><a href="function.file-exists.php" class="function">file_exists()</a></span></li>
      <li><span class="function"><a href="function.function-exists.php" class="function">function_exists()</a></span></li>
     </ul>
    </p>
   </div>

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