The problem is likely because you are mixing $op and $_POST[‘operation’]. Also, you have a concern about your if statements. Because you return in each one, you can simplify this a great deal without increasing runtime complexity.
function total($num1, $num2, $op) {
if($op == "+")
return "$num1 + $num2 = ".($num1 + $num2);
if($op == "-")
return "$num1 - $num2 = ".($num1 - $num2);
if($op == "https://stackoverflow.com/")
return "$num1 / $num2 = ".($num1 / $num2);
return "$num1 * $num2 = ".($num1 * $num2);
}
1
solved Using a function in php