<?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 => 'ja',
  ),
  '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' => 'ja',
    '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>はスクリプト上において
    使われる行によって値が変化します。
    これらの
    &quot;マジック&quot;定数は、実行時に解決される通常の定数とは異なり、コンパイル時に解決されます。
    これらの特別な定数は大文字小文字を区別しません。
    内容は以下のとおりです:
   </p>
   <p class="para">
    <table class="doctable table">
     <caption><strong>PHP の &quot;マジック&quot; 定数</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>
         そのファイルの存在するディレクトリ。include の中で使用すると、
         インクルードされるファイルの存在するディレクトリを返します。
         つまり、これは <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>)。
         トレイトのメソッド内で  <strong><code>__CLASS__ </code></strong> を使うと、
         そのトレイトを use しているクラスの名前を返します。
        </td>
       </tr>

       <tr id="constant.trait">
        <td><strong><code><a href="language.constants.magic.php#constant.trait">__TRAIT__</a></code></strong></td>
        <td>
         トレイト名。
         トレイト名には、宣言された名前空間も含みます
         (例 <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); ?>