Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Add
  5. */
  6. if(isset($_POST['add'])) {
  7. $x = $_POST['x'];
  8. $y = $_POST['y'];
  9.  
  10. if(is_numeric($x) && is_numeric($y)) {
  11. $answer = $x + $y;
  12. } else {
  13. $answer = "Error";
  14. }
  15. }
  16.  
  17. /*
  18. * Subtract
  19. */
  20. if(isset($_POST['subtract'])) {
  21. $x = $_POST['x'];
  22. $y = $_POST['y'];
  23.  
  24. if(is_numeric($x) && is_numeric($y)) {
  25. echo $x + $y;
  26. $answer = $x - $y;
  27. } else {
  28. $answer = "Error";
  29. }
  30. }
  31.  
  32. /*
  33. * Multiply
  34. */
  35. if(isset($_POST['multiply'])) {
  36. $x = $_POST['x'];
  37. $y = $_POST['y'];
  38.  
  39. if(is_numeric($x) && is_numeric($y)) {
  40. $answer = $x * $y;
  41. } else {
  42. $answer = "Error";
  43. }
  44. }
  45.  
  46. /*
  47. * Divide
  48. */
  49. if(isset($_POST['divide'])) {
  50. $x = $_POST['x'];
  51. $y = $_POST['y'];
  52.  
  53. if($y == 0) {
  54. $answer = "INF";
  55. } else if(is_numeric($x) && is_numeric($y)) {
  56. $answer = $x / $y;
  57. } else {
  58. $answer = "Error";
  59. }
  60. }
  61.  
  62. /*
  63. * Square
  64. */
  65. if(isset($_POST['square'])) {
  66. $x = $_POST['x'];
  67. $y = $_POST['y'];
  68.  
  69. if(is_numeric($x)) {
  70. $answer = pow($x, 2);
  71. } else {
  72. $answer = "Error";
  73. }
  74. }
  75.  
  76. /*
  77. * Power
  78. */
  79. if(isset($_POST['power'])) {
  80. $x = $_POST['x'];
  81. $y = $_POST['y'];
  82.  
  83. if(is_numeric($x) && is_numeric($y)) {
  84. $answer = pow($x, $y);
  85. } else {
  86. $answer = "Error";
  87. }
  88. }
  89.  
  90. /*
  91. * Root
  92. */
  93. if(isset($_POST['root'])) {
  94. $x = $_POST['x'];
  95. // $y = $_POST['y'];
  96.  
  97. if(is_numeric($x)) {
  98. $answer = sqrt($x);
  99. } else {
  100. $answer = "Error";
  101. }
  102. }
  103.  
  104. /*
  105. * Table
  106. */
  107. if(isset($_POST['table'])) {
  108. $x = $_POST['x'];
  109. $y = $_POST['y'];
  110.  
  111. $tafel = array();
  112.  
  113. for($i = 1 ; $i < 11 ; $i++) {
  114. $aq = $x * $i;
  115. $tafel[]+=$aq;
  116.  
  117. }
  118.  
  119. $answer = implode(', ', $tafel);
  120. }
  121.  
  122. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement