简单计算器 第一次。。
<html>
<head>
<title>计算器</title>
<head>
<body style="text-align:center"; >
<?php
$shuru=$_POST['shuru'];
if($shuru){
if(!is_numeric($shuru)){
echo '请输入数字';
}
$xieru=$_POST['xieru'];
if(!is_numeric($xieru)){
echo '请输入数字';
}
}
$fuhao=$_POST['fuhao'];
if($fuhao=='+'){
$zhi=$shuru+$xieru;
}
if($fuhao=='-'){
$zhi=$shuru-$xieru;
}
if($fuhao=='*'){
$zhi=$shuru*$xieru;
}
if($fuhao=='/'){
if($xieru=='0'){
echo '除数不能为0';
}else{
$zhi=$shuru/$xieru;}
}
if($fuhao=='%'){
$zhi=$shuru%$xieru;
}
?>
<form action="zye4.php" method="POST" >
<table style="border:1px solid #888; height:100px; background: #888">
<caption>计算器</caption>
<tr>
<th><input type="text" name="shuru" value="<?php echo $shuru; ?>"></th>
<th>
<select name="fuhao">
<option value="+"<?php echo $_POST['fuhao']=='+'?'selected':'' ?>>+</option>
<option value="-"<?php echo $_POST['fuhao']=='-'?'selected':'' ?>>-</option>
<option value="*"<?php echo $_POST['fuhao']=='*'?'selected':'' ?>>x</option>
<option value="/"<?php echo $_POST['fuhao']=='/'?'selected':'' ?>>/</option>
<option value="%"<?php echo $_POST['fuhao']=='%'?'selected':'' ?>>%</option>
</th>
<th><input type="text" name="xieru" value="<?php echo $xieru; ?>"></th>
<th>=</th>
<th><input type="text" name="zhi" value="<?php echo $zhi; ?>"></th><br>
<th><input type="submit" name="tijiao" value="计算"></th>
</tr>
</table>
<body>
</html>
写出来心情不错。。。