Minor rewrite magic constants section to focus on PHP 5. Changelog added.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@334472 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Maciej Sobaczewski 2014-08-04 07:48:40 +00:00
parent 59b4b899d3
commit 9f88a8b814

View file

@ -232,9 +232,6 @@ echo ANOTHER_CONST;
<entry>
The full path and filename of the file. If used inside an include,
the name of the included file is returned.
Since PHP 4.0.2, <constant>__FILE__</constant> always contains an
absolute path with symlinks resolved whereas in older versions it contained relative path
under some circumstances.
</entry>
</row>
<row xml:id="constant.dir">
@ -244,23 +241,18 @@ echo ANOTHER_CONST;
the directory of the included file is returned. This is equivalent
to <literal>dirname(__FILE__)</literal>. This directory name
does not have a trailing slash unless it is the root directory.
(Added in PHP 5.3.0.)
</entry>
</row>
<row xml:id="constant.function">
<entry><constant>__FUNCTION__</constant></entry>
<entry>
The function name. (Added in PHP 4.3.0) As of PHP 5 this constant
returns the function name as it was declared (case-sensitive). In
PHP 4 its value is always lowercased.
The function name.
</entry>
</row>
<row xml:id="constant.class">
<entry><constant>__CLASS__</constant></entry>
<entry>
The class name. (Added in PHP 4.3.0) As of PHP 5 this constant
returns the class name as it was declared (case-sensitive). In PHP
4 its value is always lowercased. The class name includes the namespace
The class name. The class name includes the namespace
it was declared in (e.g. <literal>Foo\Bar</literal>).
Note that as of PHP 5.4 __CLASS__ works also in traits. When used
in a trait method, __CLASS__ is the name of the class the trait
@ -270,24 +262,20 @@ echo ANOTHER_CONST;
<row xml:id="constant.trait">
<entry><constant>__TRAIT__</constant></entry>
<entry>
The trait name. (Added in PHP 5.4.0) As of PHP 5.4 this constant
returns the trait as it was declared (case-sensitive). The trait name includes the namespace
The trait name. The trait name includes the namespace
it was declared in (e.g. <literal>Foo\Bar</literal>).
</entry>
</row>
<row xml:id="constant.method">
<entry><constant>__METHOD__</constant></entry>
<entry>
The class method name. (Added in PHP 5.0.0) The method name is
returned as it was declared (case-sensitive).
The class method name.
</entry>
</row>
<row xml:id="constant.namespace">
<entry><constant>__NAMESPACE__</constant></entry>
<entry>
The name of the current namespace (case-sensitive). This constant
is defined in compile-time (Added in PHP 5.3.0).
The name of the current namespace.
</entry>
</row>
</tbody>
@ -301,6 +289,64 @@ echo ANOTHER_CONST;
<function>file_exists</function>&listendand;
<function>function_exists</function>.
</para>
<sect2 xml:id="language.constants.predefined.changelog">
<title>Changelog</title>
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.4.0</entry>
<entry>
Added <constant>__TRAIT__</constant> constant
</entry>
</row>
<row>
<entry>5.3.0</entry>
<entry>
Added <constant>__DIR__</constant> and <constant>__NAMESPACE__</constant> constants
</entry>
</row>
<row>
<entry>5.0.0</entry>
<entry>
Added <constant>__METHOD__</constant> constant
</entry>
</row>
<row>
<entry>5.0.0</entry>
<entry>
Before this version values of some magic constants were always lowercased.
All of them are case-sensitive now (contain names as they were declared).
</entry>
</row>
<row>
<entry>4.3.0</entry>
<entry>
Added <constant>__FUNCTION__</constant> and <constant>__CLASS__</constant> constants
</entry>
</row>
<row>
<entry>4.0.2</entry>
<entry>
<constant>__FILE__</constant> always contains an absolute path with symlinks
resolved whereas in older versions it contained relative path
under some circumstances
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</sect2>
</sect1>
</chapter>