philip Sat Jan 18 01:42:27 2003 EDT
Modified files:
/phpdoc/en/language constants.xml
Log:
Document the special magical constants (__LINE__ and friends). This also
closes bug #19196
Index: phpdoc/en/language/constants.xml
diff -u phpdoc/en/language/constants.xml:1.26 phpdoc/en/language/constants.xml:1.27
--- phpdoc/en/language/constants.xml:1.26 Wed Oct 9 05:50:22 2002
+++ phpdoc/en/language/constants.xml Sat Jan 18 01:42:27 2003
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.26 $ -->
+<!-- $Revision: 1.27 $ -->
<chapter id="language.constants">
<title>Constants</title>
<simpara>
A constant is a identifier (name) for a simple value. As the name
suggests, that value cannot change during the execution of the
- script. (The 'magic constants' <constant>__FILE__</constant> and
- <constant>__LINE__</constant> appear to be an exception to this,
- but they're not actually constants.) A constant is case-sensitive
- by default. By convention constant identifiers are always
- uppercase.
+ script (except the <link linkend="language.constants.predefined">
+ magic constants</link> which aren't actually constants).
+ A constant is case-sensitive by default. By convention constant
+ identifiers are always uppercase.
</simpara>
<para>
The name of a constant follows the same rules as any label in PHP. A
@@ -132,10 +131,57 @@
are available, either via dynamic loading or because they have
been compiled in.
</simpara>
+
+ <para>
+ There are four magical constants that change depending on
+ where they're used. For example, the value of
+ <constant>__LINE__</constant> depends on the line that it's
+ used on in your script. These special constants are
+ case-insensitive and are as follows:
+ </para>
+ <para>
+ <table>
+ <title>A few "magical" PHP "constants"</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><constant>__LINE__</constant></entry>
+ <entry>
+ The current line number of the file.
+ </entry>
+ </row>
+ <row>
+ <entry><constant>__FILE__</constant></entry>
+ <entry>
+ The full path and filename of the file.
+ </entry>
+ </row>
+ <row>
+ <entry><constant>__FUNCTION__</constant></entry>
+ <entry>
+ The function name. This was added in PHP 4.3.0
+ </entry>
+ </row>
+ <row>
+ <entry><constant>__CLASS__</constant></entry>
+ <entry>
+ The class name. This was added in PHP 4.3.0
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
<simpara>
A list of predefined constants is available in the section <link
- linkend="reserved.constants">Predefined constants</link>.
+ linkend="reserved.constants">Reserved predefined constants</link>.
</simpara>
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php