标签:style blog io color os sp for on div
<?php error_reporting(E_ALL & ~E_NOTICE); if( isset($_POST[‘sub‘]) ){ $bz = true; $errs = "有以下问题:<br>"; if($_POST[‘num1‘]==""){ $bz = false; $errs .= "第一个数为空 <br>"; } if($_POST[‘num2‘]==""){ $bz = false; $errs .= "第二个数为空 <br>"; } if($bz){ $sum = ""; switch($_POST[‘ysf‘]){ case ‘+‘: $sum = $_POST[‘num1‘] + $_POST[‘num2‘]; break; case ‘-‘: $sum = $_POST[‘num1‘] - $_POST[‘num2‘]; break; case ‘*‘: $sum = $_POST[‘num1‘] * $_POST[‘num2‘]; break; case ‘/‘: $sum = $_POST[‘num1‘] / $_POST[‘num2‘]; break; } } } ?> <html> <head> <title>Easy Calculator</title> </head> <body> <table border="1" width="400" align="center"> <form action="index.php" method="post"> <caption><h1>easy calculator</h1></caption> <tr> <td> <input type="text" size="5" name="num1" value="<?php echo $_POST[‘num1‘] ?>" /> <br> </td> <td> <select name="ysf"> <option <?php if($_POST[‘ysf‘]=="+") echo "selected"; ?> value="+">+</option> <option <?php if($_POST[‘ysf‘]=="-") echo "selected"; ?> value="-">-</option> <option <?php if($_POST[‘ysf‘]=="*") echo "selected"; ?> value="*">*</option> <option <?php if($_POST[‘ysf‘]=="/") echo "selected"; ?> value="/">/</option> </select> </td> <td> <input type="text" size="5" name="num2" value="<?php echo $_POST[‘num2‘] ?>" /> <br> </td> <td> <input type="submit" name="sub" value="计算" /> <br> </td> <tr> <tr> <td colspan="4"> <?php if($bz){ echo "计算结果:{$_POST[‘num1‘]} {$_POST[‘ysf‘]} {$_POST[‘num2‘]} = {$sum} <br>"; } else{ echo $errs; } ?> </td> </tr> </form> </table> </body> </html>
标签:style blog io color os sp for on div
原文地址:http://www.cnblogs.com/fish7/p/4120037.html