<?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;
?>
时间: 2024-10-14 09:30:22