0

Php file must be a calculator. Help me please.

Code you can see in my profil(name hz).

22nd Nov 2016, 11:07 AM
V13
V13 - avatar
7 Réponses
+ 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.
22nd Nov 2016, 11:19 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
Hey please see my updated answer.
22nd Nov 2016, 11:26 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 2
Then translate it
22nd Nov 2016, 11:31 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
he is public
22nd Nov 2016, 11:17 AM
V13
V13 - avatar
0
Thank
22nd Nov 2016, 11:21 AM
V13
V13 - avatar
0
Sorry, I don't speak english very well.
22nd Nov 2016, 11:30 AM
V13
V13 - avatar
0
ok
22nd Nov 2016, 11:32 AM
V13
V13 - avatar