我是一个没有任何脚本的简单计算器,但它不起作用,当我点击按钮时,哪个函数被声明它不能正常工作,
<html>
<head>
</head>
<body>
<form method="post" action="">
<table align="center" border="1px" bordercolor="#CC0033" bgcolor="#99CC00">
<tr>
<td>
Number 1:</td><td><input type="text" name="number1"></td>
</tr>
<tr>
<td>
Number 2:</td><td> <input type="text" name="number2"></td>
</tr>
<tr>
<td>
Get Result:</td><td> <input type="text" name="total"> </td>
</tr>
<tr>
<td class="2">
<input type="button" value="ADD" onclick="addition()">
<input type="button" value="SUB" onclick="subtraction()">
<input type="button" value="MUL" onclick="multiply();">
<input type="button" value="DIV" onclick="division()">
<input type="button" value="MOD" onclick="modulus()">
</td>
</tr>
</table>
</form>
</body>
</html>
Bellow 是一个 php 函数,我是 crated.but is not working
<?php
error_reporting(E_ALL ^ E_NOTICE);
//if()
function addition(){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
echo $total=$number1+$number2;
}
function subtraction(){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
echo $total=$number1-$number2;
}
function multiply(){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
echo $total=$number1*$number2;
}
function division(){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
echo $total=$number1/$number2;
}
function modulus(){
$number1=$_POST['number1'];
$number2=$_POST['number2'];
echo $total=$number1%$number2;
}
?>