锟斤拷锟斤拷锟斤拷 define() 锟斤拷锟斤拷锟斤拷锟斤拷锟藉常锟斤拷锟斤拷锟斤拷 PHP 5.3.0 锟皆后,匡拷锟斤拷使锟斤拷 const 锟截硷拷锟斤拷锟斤拷锟洁定锟斤拷之锟解定锟藉常锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟藉,锟酵诧拷锟斤拷锟劫改憋拷锟斤拷锟饺★拷锟斤拷锟斤拷濉�
锟斤拷锟斤拷只锟杰帮拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷o拷boolean锟斤拷integer锟斤拷float 锟斤拷 string锟斤拷锟斤拷锟斤拷锟皆讹拷锟斤拷 resource 锟斤拷锟斤拷锟斤拷锟斤拷应锟斤拷锟斤拷锟斤拷锟解,锟斤拷为锟斤拷锟斤拷刹锟斤拷锟皆わ拷系慕锟斤拷锟斤拷
锟斤拷锟皆简单碉拷通锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷取锟矫筹拷锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷锟斤拷锟酵拷锟�锟斤拷应锟斤拷锟节筹拷锟斤拷前锟斤拷锟斤拷锟� $ 锟斤拷锟脚★拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷嵌锟教拷模锟揭诧拷锟斤拷锟斤拷煤锟斤拷锟� constant() 锟斤拷锟斤拷取锟斤拷锟斤拷锟斤拷值锟斤拷锟斤拷 get_defined_constants() 锟斤拷锟皆伙拷锟斤拷锟斤拷锟斤拷讯锟斤拷锟侥筹拷锟斤拷锟叫憋拷
Note: 锟斤拷锟斤拷锟酵o拷全锟街o拷锟斤拷锟斤拷锟节诧拷同锟斤拷锟斤拷锟街空硷拷锟叫★拷锟斤拷锟斤拷味锟斤拷锟斤拷锟斤拷
TRUE
锟斤拷 $TRUE 锟角诧拷同锟侥★拷
锟斤拷锟绞癸拷锟斤拷锟揭伙拷锟轿达拷锟斤拷锟侥筹拷锟斤拷锟斤拷PHP 锟劫讹拷锟斤拷要锟斤拷锟角该筹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷郑锟斤拷锟酵拷锟斤拷址锟斤拷锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷锟紺ONSTANT 锟斤拷应 "CONSTANT"锟斤拷锟斤拷锟斤拷时锟斤拷锟斤拷锟斤拷一锟斤拷 E_NOTICE 锟斤拷锟侥达拷锟襟。参硷拷锟街诧拷锟斤拷为什么 $foo[bar] 锟角达拷锟斤拷模锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� define() 锟斤拷 bar 锟斤拷锟斤拷为一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街伙拷锟斤拷锟斤拷欠锟斤拷锟斤拷锟侥筹拷锟斤拷锟斤拷锟斤拷锟� defined() 锟斤拷锟斤拷锟斤拷
锟斤拷锟斤拷锟酵憋拷锟斤拷锟斤拷锟斤拷锟铰诧拷同锟斤拷
Example #1 锟斤拷锟藉常锟斤拷
<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // 锟斤拷锟� "Constant" 锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷示锟斤拷锟斤拷锟斤拷锟斤拷锟较�
?>
Example #2 使锟矫关硷拷锟斤拷 const 锟斤拷锟藉常锟斤拷
<?php
// 锟斤拷锟铰达拷锟斤拷锟斤拷 PHP 5.3.0 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
const CONSTANT = 'Hello World';
echo CONSTANT;
?>
Note:
锟斤拷使锟斤拷 define() 锟斤拷锟斤拷锟藉常锟斤拷锟洁反锟斤拷锟角o拷使锟斤拷 const 锟截硷拷锟街讹拷锟藉常锟斤拷锟斤拷锟诫处锟斤拷锟筋顶锟剿碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷为锟矫此凤拷锟斤拷锟斤拷锟节憋拷锟斤拷时锟斤拷锟斤拷摹锟斤拷锟斤拷锟斤拷味锟脚诧拷锟斤拷锟节猴拷锟斤拷锟节o拷循锟斤拷锟斤拷锟皆硷拷 if 锟斤拷锟街拷锟斤拷锟� const 锟斤拷锟斤拷锟藉常锟斤拷锟斤拷
锟轿硷拷锟洁常锟斤拷锟斤拷