<!--常量定义define(常量名,常量值,true)true表示常量名大小写一样--> <!--取值有二种,一种直接赋值,另一种用函数constant(常量名)动态获取常量值--> <!--函数defined(常量名)判定常量是否已定义--> <?php error_reporting(E_ALL ^ E_NOTICE); //忽略错误 define("zhaowanshi","myname我的名字"); echo zhaowanshi; echo '<br />'; echo ZHAOWANSHI; echo '<br>'; define("taizhou","浙江台州是我所在的地方",true); echo taizhou; echo '<br>'; echo TAIZHOU; echo '<br>'; $name = "TAIZHOU"; echo constant($name); echo '<br>'; echo defined("TAIZHOU"); ?>
The above has introduced PHP self-study no00013 constant definition and value determination to determine whether it has been defined, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.