html head head body form method POST Write number one input type int n

 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
<html>
<head>
</head>
<body>
<form method="POST">
<p> Write number one</p>
<input type="int" name="numOne">
<p> Write number two</p>
<input type="int" name="numTwo">
<p> Select operator</p>
<select name="operator">
<option value="+" >+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="submit">
</form>
</body>
</html>
<?php
function operation(int $numOne, int $numTwo, string $operator){
if (!empty($numTwo) && !empty($numTwo) && !empty($operator)){
if ($operator =='+'){
return $numOne + $numTwo;
} elseif ($operator == '-'){
return $numOne - $numTwo;
}elseif ($operator == '*'){
return $numOne * $numTwo;
}elseif ($operator == '/'){
return $numOne / $numTwo;
}
}else {
echo "Choose all parameters ";
}
}
echo operation($_POST['numOne'],$_POST['numTwo'],$_POST['operator']);