$p明明是变量,也可以调用constant()方法吗
<?php
$p="";
//定义圆周率的两种取值
define("PI1",3.14);
define("PI2",3.142);
//定义值的精度
$height = "中";
//根据精度返回常量名,将常量变成了一个可变的常量
if($height == "中"){
$p = "PI1";
}else if($height == "低"){
$p = "PI2";
}
$r=1;
$area = constant($p)*$r*$r;
echo $area;
?>