<?php //最上方 include("functions.php"); if ( isset ($_REQUEST['myh']) ){ $myh = $_REQUEST['myh']; $myw = $_REQUEST['myw']; $mybmi = $myw / $myh / $myh * 10000 ; $mymsg = <<<eof <div><p>你的 BMI 是$mybmi </p></div> eof; echo $mymsg; } ?> //input內 if (isset($myh)) echo "value='$myh'"; //最下方 if (isset($mymsg)) echo $mymsg;