Blogger Information
Blog 67
fans 0
comment 2
visits 72045
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP switch计算器
搁浅
Original
1206 people have browsed it
  1. <form action="1.php" method="post">
  2. <input type="number" name="num1" id="num1">
  3. <input type="number" name="num2" id="num2">
  4. <select name="fu">
  5. <option value="+">+</option>
  6. <option value="-">-</option>
  7. <option value="*">*</option>
  8. <option value="/">/</option>
  9. </select>
  10. <button>提交</button>
  11. </form>
  12. <?php
  13. if(!empty($_POST['num1'])){
  14. $num1=floatval($_POST['num1']);
  15. $num2=floatval($_POST['num2']);
  16. $fu=$_POST['fu'];
  17. }
  18. if(!empty($_POST['num1'])){
  19. switch ($fu) {
  20. case '+':
  21. echo $num1+$num2;
  22. break;
  23. case '-':
  24. echo $num1-$num2;
  25. break;
  26. case '*':
  27. echo $num1*$num2;
  28. break;
  29. case '/':
  30. echo $num1/$num2;
  31. break;
  32. }
  33. }
  34. ?>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post