//定義值的精度$height = "中";//根據(jù)精度返回常量名,將常量變成了一個可變的常量if($height == "中"){? ? $p = "PI1";}else if($height == "低"){ $p = "PI2";}
2 回答

MIseryT
TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個贊
<?php?
$p="";
//定義圓周率的兩種取值
define("PI1",3.14);
define("PI2",3.142);
//定義值的精度
$height = "中";
//根據(jù)精度返回常量名,將常量變成了一個可變的常量
if($height == "中"){
? ? $p = "PI1";
}else if($height == "低"){
$p = "PI2";
}
$r=1;
$area = constant($p)*$r*$r;
echo $area;
?>
- 2 回答
- 0 關(guān)注
- 1441 瀏覽
添加回答
舉報(bào)
0/150
提交
取消