Table of Content
定义了常量,还要获取常量的值,除了通过我们指定的常量名直接获取外,还可以通过 constant()
函数来获取:
<?php
define("PI1",3.141592653);
define("PI2",3.142);
$p = "PI2";
$var_pi1 = PI1;
echo $var_pi1;
echo "\n";
$var_pi2 = constant($p);
echo $var_pi2;
?>