OperService.class.php

<?php
class OperSerVice{
public function getResult($num1,num2,oper){
switch($oper){
case "+":
return $num1+$num2;
break;
case "-":
return $num1-$num2;
break;
case "*":
return $num1*$num2;
break;
case

return $num1/$num2;
break;
default:
echo "操作符错误";
}}}
?>
时间: 2024-10-25 13:34:52

OperService.class.php的相关文章

CalParcess.php.

<?php require_once "OperSerVice.class.php"; //接受三个数 //isset if(!isset($_REQUEST['NUM1'])){ $num1=$_REQUEST['NUM1'];} if(!isset($_REQUEST['NUM2'])){ $num2=$_REQUEST['NUM2'];} if(!isset($_REQUEST['oper'])){ $oper=$_REQUEST[;OPER'];} //创建对象 $Ope