• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jan 29th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. <?php
2. if (!empty(\$_POST['firstNumber']))
3. {
4.     \$first = \$_POST['firstNumber'];
5. }
6. else
7. {
8.     \$first = '';
9. }
10.
11. if (!empty(\$_POST['secondNumber']))
12. {
13.     \$second = \$_POST['secondNumber'];
14. }
15. else
16. {
17.     \$second = '';
18. }
19.
20. switch (\$_REQUEST['operation']) {
21.     case "+":
24.         break;
25.     case "-":
26.         \$result = new Subtraction();
27.         \$result -> Substract(\$first, \$second);
28.         break;
29.     case "*":
30.         \$result = new Multiplication();
31.         \$result -> Multiply(\$first, \$second);
32.         break;
33.     case "/":
34.         \$result = new Division();
35.         \$result -> Divide(\$first, \$second);
36.         break;
37.     default:
38.         echo  '¯\_(ツ)_/¯';
39. }
40.
41. class Operations {}
43. {
45.     {
46.         return \$first + \$second;
47.     }
48. }
49. class Subtraction extends Operations
50. {
51.     public function Substract(\$first, \$second)
52.     {
53.         return \$first - \$second;
54.     }
55. }
56. class Multiplication extends Operations
57. {
58.     public function Multiply(\$first, \$second)
59.     {
60.         return \$first * \$second;
61.     }
62. }
63. class Division extends Operations
64. {
65.     public function Divide(\$first, \$second)
66.     {
67.         if(\$second == 0 )
68.         {
69.             echo  '¯\_(ツ)_/¯';
70.             return;
71.         }
72.         return \$first / \$second;
73.     }
74. }
75. include "data.html";
76. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top