-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.php
67 lines (51 loc) · 1.53 KB
/
calculator.php
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
60
61
62
63
64
65
66
67
<?php
$option_ = $_POST['option'];//selected option comes in from HTML FILE
$firstfield_ = $_POST['firstfield'];//this is the first numeric entry
$secondfield_ = $_POST['secondfield'];//this is the second numeric entry
if (empty($firstfield_)) {//if not set then = 0
$firstfield_=0;
}
if (empty($secondfield)) {//if not set then = 0
$secondfield=0;
}
//these are all the functions for add, devide, factorial, multiply, multiplyrecursive, reserve, subtract
Include("include/multiplyrec.php");
Include("include/multiply.php");
Include("include/devide.php");
Include("include/add.php");
Include("include/subtract.php");
Include("include/factorial.php");
Include("include/reverse.php");
choice($option_, $firstfield_,$secondfield_);
function choice($option, $firstfield, $secondfield){//this will calculate with a switch which option you picked and execute it.
switch ($option) {
case 'add':
echo add($firstfield,$secondfield);
break;
case 'subtract':
echo subtract($firstfield,$secondfield);
break;
case 'multiply':
echo multiply($firstfield,$secondfield);
break;
case 'devide':
echo devide($firstfield,$secondfield);
break;
case 'factorial':
echo factorial($firstfield|$secondfield);
break;
case 'fibonacci':
echo fibonacci($firstfield|$secondfield);
break;
case 'reverse':
echo reverse($firstfield|$secondfield);
break;
case 'multiplyrec':
echo multiplyrec($firstfield|$secondfield);
break;
default:
echo "something went wrong...sorry";
break;
}
}
?>