I am trying to get the return value to display but it is only doing the final else procedure. Something is wrong with my if statements... I am using an html page to call this php page... When i put in results, regardless of the operation it only displays the multiplication value
function total($num1, $num2, $op) {
if($op == "+"){
$total = "$num1 + $num2 = ".($num1 + $num2);
return $total;
} elseif($_POST['operation'] == "-"){
$total = "$num1 - $num2 = ".($num1 - $num2);
return $total;
} elseif($_POST['operation'] == "/"){
$total = "$num1 / $num2 = ".($num1 / $num2);
return $total;
} else{
$total = "$num1 * $num2 = ".($num1 * $num2);
return $total;
}
}
echo total($num1, $num2, $op);