There is another magic constant not mentioned above: __COMPILER_HALT_OFFSET__ - contains where the compiler halted - see http://www.php.net/manual/function.halt-compiler.php for further information.
![]() | 魔术常量PHP 向它运行的任何脚本提供了大量的预定义常量。不过很多常量都是由不同的扩展库定义的,只有在加载了这些扩展库时才会出现,或者动态加载后,或者在编译时已经包括进去了。 有五个魔术常量根据它们使用的位置而改变。例如 __LINE__ 的值就依赖于它在脚本中所处的行来决定。这些特殊的常量不区分大小写,如下:
表格 13-1. 几个 PHP 的“魔术常量”
参见 get_class(),get_object_vars(),file_exists() 和function_exists()。 ![]()
warhog at warhog dot net
19-Dec-2005 05:33
There is another magic constant not mentioned above: __COMPILER_HALT_OFFSET__ - contains where the compiler halted - see http://www.php.net/manual/function.halt-compiler.php for further information.
stalker at NOSPAM dot ruun dot de
17-Dec-2005 05:14
To czabu:
vijaykoul_007 at rediffmail dot com
22-Sep-2005 12:59
the difference between
karl __at__ streetlampsoftware__dot__com
04-Mar-2005 05:39
Note that the magic constants cannot be included in quoted strings.
csaba at alum dot mit dot edu
03-Mar-2005 08:04
Sometimes you might want to know whether a script is the top level script or whether it has been included. That could be useful if you want to reuse the routines in another script, but you don't want to separate them out. Here's a way that seems to be working for me (for both Apache2 module and CLI versions of PHP) on my Win XP Pro system.
lm arobase bible point ch
09-Dec-2004 06:17
in reply to x123 at bestof dash inter:
claude at NOSPAM dot claude dot nl
18-Jul-2004 11:29
Note that __CLASS__ contains the class it is called in; in lowercase. So the code:
warhog at warhog dot net
07-Feb-2004 04:49
just to read out the filename of the currently proceeded file use
hixon at colorado dot edu
16-May-2003 08:21
You can use the following in files that you want to include, but not run directly. The script will exit if it's run as the top-level script, but will not exit if it's included from another script. Of course this won't work in the command line mode.
kop at meme dot com
14-Feb-2003 07:34
The keywords TRUE and FALSE (case insensitive), which represent their respective boolean values, are worth noting here.
darwin[at]buchner[dot]net
15-Mar-2002 08:54
As of version 4.0.6, there is also a handy predefined DIRECTORY_SEPARATOR constant which you can use to make you scripts more portatable between OS's with different directory structures.
| ![]() | ||||||||||||