BBS水木清华站∶精华区
发信人: thinkin (强强), 信区: Linux
标 题: calculator
发信站: BBS 水木清华站 (Thu Feb 17 11:00:36 2000)
<form action=" <? echo $PHP_SELF ?>" method="post">
1st number:<input type=text name=num1><br>
2nd number:<input type=text name=num2><br>
<p>
What operation would you like to perform?<br>
<input type=radio name=operation value="plus" checked>Add<br>
<input type=radio name=operation value="minus">Subtract<br>
<input type=radio name=operation value="X">Multiply<br>
<input type=radio name=operation value="divided by">Divide<br>
<input type=submit><input type=reset>
</form>
</body>
</html>
The answer to <? echo $num1;?> <?echo $operation;?> <? echo $num2;?>
is:<br>
<h1>
<?php
if ($operation == "plus")
{$x = $num1 + $num2;
print $x;}
elseif ($operation == "minus")
{$x = $num1 - $num2;
print $x;}
elseif ($operation == "X")
{$x = $num1 * $num2;
print $x;}
else
{$x = $num1 / $num2;
print $x;}
?>
</h1>
--
人生到处知何似?
应似飞鸿踏雪泥。
泥上偶然留指爪,
鸿飞那复计东西!
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.37.191]
BBS水木清华站∶精华区