php常量 define() constant() , defined()
define――定义常量,若定义true,则读取时不区分大小写
bool define( string name, mixed value [, bool case_insensitive])
常量只能包含标量数据(boolean,integer,float和string)。
define("CONSTANT","Hello world.");
echoCONSTANT;// outputs "Hello world."
echoConstant;// outputs "Constant" and issues a notice.
define("GREETING","Hello you.",true);
echoGREETING;// outputs "Hello you."
echoGreeting;// outputs "Hello you."
?
?
========================================
constant()――读取常量
mixedconstant( string name)
?
define("MAXSIZE",100);
echoMAXSIZE;
echoconstant("MAXSIZE");// same thing as the previous line
?
===============================
?
?
booldefined( string name)
?
if (defined('CONSTANT')) {
????echoCONSTANT;
}
?
======================================================
?
预定义常量
?
__FILE__?? 取得文件的物理地址?注:左右各2条下划线
?
echo __FILE__??? //C:\wamp\www\T1\1.php
?
?
?
?