1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/10/10 * Time: 14:01 */ $result=0; if($_POST){ $num1=$_POST['num1']; $num2=$_POST['num2']; $num3=$_POST['num3']; $opearte=$_POST['opearte']; // echo $num1,$num2,$num3,$opearte; switch ($opearte){ case '+': $result=$num1+$num2; break; case '-': $result=$num1-$num2; break; case '*': $result=$num1*$num2; break; case '/': $result=$num1/$num2; break; default: } // var_dump($result); // 插入一个inpute // echo "<a href='insert.php'><input type=\"text\" value='$result' name='num3'/></a>"; } ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="jquery.min.js" type="text/javascript" charset="utf-8"></script> </head> <body> <form action="" method="post"> <input type="text" name="num1" value=""> <select name="opearte"> <option value="+">+</option> <option value="-">-</option> <option value="*">*</option> <option value="/">/</option> </select> <input type="text" name="num2" value=""> <button>=</button> <input type="text" name="num3" echo value="" > </form> </body> </html>
|