超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<常量表达式>
Last updated: Fri, 22 Jun 2007

预定义常量

PHP 向它运行的任何脚本提供了大量的预定义常量。不过很多常量都是由不同的扩展库定义的,只有在加载了这些扩展库时才会出现,或者动态加载后,或者在编译时已经包括进去了。

有四个魔术常量根据它们使用的位置而改变。例如 __LINE__ 的值就依赖于它在脚本中所处的行来决定。这些特殊的常量不区分大小写,如下:

表格 13-1. 几个 PHP 的“魔术常量”

名称说明
__LINE__ 文件中的当前行号。
__FILE__ 文件的完整路径和文件名。
__FUNCTION__ 函数名称(这是 PHP 4.3.0 新加的)。
__CLASS__ 类的名称(这是 PHP 4.3.0 新加的)。
__METHOD__ 类的方法名(这是 PHP 5.0.0 新加的)。

预定义常量的列表见预定义常量一节。




add a note add a note User Contributed Notes
预定义常量
cbaker at cbaker dot org
28-Nov-2001 07:25
Within a parent file, the value of __file__ is the entire actual path of the file, whereas within an included file it is just the file name. This can have an entirely different path than the SCRIPT_FILENAME constant on servers configured with simlinks. (tested on PHP 4.04)

<常量表达式>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22