使用php做的简易计算器
能够进行+,-,*,/运算.
如下图
if (isset($_POST['button'])) {
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$op = $_POST['op'];
switch ($_POST['op']) {
case '+':
$result = $num1 + $num2;
break;
case '-':
$result = $num1 - $num2;
break;
case '*':
$result = $num1 * $num2;
break;
case '/':
$result = $num1 / $num2;
break;
}
echo <<
window.οnlοad=function(){
document.getElementById('num1').value = '$num1';
document.getElementById('op').value = '$op';
document.getElementById('num2').value = '$num2';
document.getElementById('result').value = '$result';
}
str;
}
?>
+
-
*
/
标签:document,num1,num2,计算器,value,getElementById,result,简单,PHP
来源: https://www.cnblogs.com/wjw9/p/10962739.html