0
Php file must be a calculator. Help me please.
Code you can see in my profil(name hz).
7 Respuestas
+ 2
<?php
if(isset($_POST["a"])&&isset($_POST["d"])&&isset($_POST["b"])){
calc($_POST["a"],$_POST["d"],$_POST["b"]);
}
function calc($a,$d,$b){
switch($d){
case "+":$sum = $a + $b; break;
case "-":$sum = $a - $b; break;
case "*":$sum = $a * $b; break;
case "/":$sum = $a / $b; break;
}
echo $sum;
}
?>
Your program was correct, but with a problem. If there is no data in text field and you use get or post method. PHP try to get it. due to empty field it show you an error. use isset function in this. Like I have done.
note: playground PHP coder is static means one way. If you try to send input to PHP program and wanted to get output you will not get. Please use your computer or laptop install xammp and run PHP code. It will run.
+ 2
Hey please see my updated answer.
+ 2
Then translate it
0
he is public
0
Thank
0
Sorry, I don't speak english very well.
0
ok