1 回答

TA贡献1784条经验 获得超7个赞
你可以试试这个
//variables and result
function bmi() {
foreach ($_POST as $name => $value) {
switch ($name) {
case 'height':
$height = floatval($value);
break;
case 'weight':
$weight = floatval($value);
break;
case 'waist':
$waist = floatval($value);
break;
}
}
return round($weight / ($height * $waist),1);
}
和
<?php
//handles if empty or 0 input
if (!empty($_POST['height']) && !empty($_POST['weight']) && !
empty($_POST['waist'])) :
?>
<p id="result">Your score is <?php echo bmi();
endif;
?>
- 1 回答
- 0 关注
- 116 浏览
添加回答
举报