<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'language.constants.magic.php',
    1 => 'Magic constants',
    2 => 'Magic constants',
  ),
  'up' => 
  array (
    0 => 'language.constants.php',
    1 => 'Constants',
  ),
  'prev' => 
  array (
    0 => 'language.constants.predefined.php',
    1 => 'Predefined constants',
  ),
  'next' => 
  array (
    0 => 'language.expressions.php',
    1 => 'Expressions',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    '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">Magic constants</h2>
   <p class="para">
    There are a few magical constants that change depending on
    where they are used. For example, the value of
    <strong><code><a href="language.constants.magic.php#constant.line">__LINE__</a></code></strong> depends on the line that it&#039;s
    used on in a script. All these &quot;magical&quot; constants are resolved
    at compile time, unlike regular constants, which are resolved at runtime. 
    These special constants are case-insensitive and are as follows:
   </p>
   <p class="para">
    <table class="doctable table">
     <caption><strong>PHP&#039;s magic constants</strong></caption>
     
      <thead>
       <tr>
        <th>Name</th>
        <th>Description</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>
         The current line number of the file.
        </td>
       </tr>

       <tr id="constant.file">
        <td><strong><code><a href="language.constants.magic.php#constant.file">__FILE__</a></code></strong></td>
        <td>
         The full path and filename of the file with symlinks resolved. If used inside an include,
         the name of the included file is returned.
        </td>
       </tr>

       <tr id="constant.dir">
        <td><strong><code><a href="language.constants.magic.php#constant.dir">__DIR__</a></code></strong></td>
        <td>
         The directory of the file. If used inside an include,
         the directory of the included file is returned. This is equivalent
         to <code class="literal">dirname(__FILE__)</code>. This directory name
         does not have a trailing slash unless it is the root directory.
        </td>
       </tr>

       <tr id="constant.function">
        <td><strong><code><a href="language.constants.magic.php#constant.function">__FUNCTION__</a></code></strong></td>
        <td>
         The function name, or <code class="literal">{closure}</code> for anonymous functions.
        </td>
       </tr>

       <tr id="constant.class">
        <td><strong><code><a href="language.constants.magic.php#constant.class">__CLASS__</a></code></strong></td>
        <td>
         The class name. The class name includes the namespace
         it was declared in (e.g. <code class="literal">Foo\Bar</code>).
         When used inside a trait method,
         <strong><code><a href="language.constants.magic.php#constant.class">__CLASS__</a></code></strong> is the name of the class the trait
         is used in.
        </td>
       </tr>

       <tr id="constant.trait">
        <td><strong><code><a href="language.constants.magic.php#constant.trait">__TRAIT__</a></code></strong></td>
        <td>
         The trait name. The trait name includes the namespace
         it was declared in (e.g. <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>
         The class method name.
        </td>
       </tr>

       <tr id="constant.property">
        <td><strong><code><a href="language.constants.magic.php#constant.property">__PROPERTY__</a></code></strong></td>
        <td>
         Only valid inside a
         <a href="language.oop5.property-hooks.php" class="link">property hook</a>.
         It is equal to the name of the property.
        </td>
       </tr>

       <tr id="constant.namespace">
        <td><strong><code><a href="language.constants.magic.php#constant.namespace">__NAMESPACE__</a></code></strong></td>
        <td>
         The name of the current namespace.
        </td>
       </tr>

       <tr id="constant.coloncolonclass">
        <td><strong><code><span class="replaceable">ClassName</span>::class</code></strong></td>
        <td>
         The fully qualified class name.
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>

   <div class="sect2">
    <h3 class="title">See Also</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); ?>