代码如下:
a small calculateNone
Add
Subtract
Multiply
Divide
Calculate
the answer is:
if(isset($_GET['submit'])){
$result1 = $_GET('num1');
$result2 = $_GET('num2');
$operator = $_GET('operator');
switch($operator){
case "None":
echo "Error,you need select a method.";
break;
case "Add":
echo $result1 + $result2;
break;
case "Subtract":
echo $result1 - $result2;
break;
case "Multiply":
echo $result1 * $result2;
break;
case "Divide":
echo $result1 / $result2;
break;
}
}
?>
运行后测试:文本框输入值后,点击 calculate 按钮返回错误:
Fatal error: Function name must be a string in /Applications/XAMPP/xamppfiles/htdocs/calculate.php on line 29
请问如何解决呢?
代码片段:
28 行 if(isset($_GET['submit'])){
29 行 $result1 = $_GET('num1');
30 行 $result2 = $_GET('num2');
31 行 $operator = $_GET('operator');