language.constants.predefined.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 126 行
HTML
126 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Magic constants</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.constants.html">Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.expressions.html">Expressions</a></div> <div class="up"><a href="language.constants.html">Constants</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="language.constants.predefined" class="sect1"> <h2 class="title">Magic constants</h2> <p class="simpara"> PHP provides a large number of <a href="reserved.constants.html" class="link">predefined constants</a> to any script which it runs. Many of these constants, however, are created by various extensions, and will only be present when those extensions are available, either via dynamic loading or because they have been compiled in. </p> <p class="para"> There are seven magical constants that change depending on where they are used. For example, the value of <b><tt>__LINE__</tt></b> depends on the line that it's used on in your script. These special constants are case-insensitive and are as follows: </p> <p class="para"> <table border="5"> <caption><b>A few "magical" PHP constants</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Name</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__LINE__</tt></b></td> <td colspan="1" rowspan="1" align="left"> The current line number of the file. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__FILE__</tt></b></td> <td colspan="1" rowspan="1" align="left"> 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, <b><tt>__FILE__</tt></b> always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__DIR__</tt></b></td> <td colspan="1" rowspan="1" align="left"> The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to <i>dirname(__FILE__)</i>. This directory name does not have a trailing slash unless it is the root directory. (Added in PHP 5.3.0.) </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__FUNCTION__</tt></b></td> <td colspan="1" rowspan="1" align="left"> 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. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__CLASS__</tt></b></td> <td colspan="1" rowspan="1" align="left"> 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. </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__METHOD__</tt></b></td> <td colspan="1" rowspan="1" align="left"> The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive). </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left"><b><tt>__NAMESPACE__</tt></b></td> <td colspan="1" rowspan="1" align="left"> The name of the current namespace (case-sensitive). This constant is defined in compile-time (Added in PHP 5.3.0). </td> </tr> </tbody> </colgroup> </table> </p> <p class="para"> See also <a href="function.get-class.html" class="function">get_class()</a>, <a href="function.get-object-vars.html" class="function">get_object_vars()</a>, <a href="function.file-exists.html" class="function">file_exists()</a> and <a href="function.function-exists.html" class="function">function_exists()</a>. </p> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.constants.html">Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.expressions.html">Expressions</a></div> <div class="up"><a href="language.constants.html">Constants</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?