echo $this->num1 - $this->num2; } public function multiply() { echo $this->num1 * $this->num2; } public function divide() { if ($this->num2 != 0) { echo $this->num1 / $this->num2; } else { echo "除数不能为0"; } } } $cal = new Cal($_POST['num1'], $_POST['num2']); switch ($_POST['op']) { case 'j': $cal->plus(); break; case '-': $cal->subtract(); break; case '*': $cal->multiply(); break; case '/': $cal->divide(); break; default: echo "参数错误";
public function agenda() { $events = \Cal::google()->events($params = ['orderBy' => 'startTime', 'singleEvents' => 'true']); return view('pages.public.agenda', compact('events')); }
{ if ($this->num3 + $this->num4 > 0) { echo $this->num1 + $this->num2 . "+" . ($this->num3 + $this->num4) . 'i'; } else { echo $this->num1 + $this->num2 . ($this->num3 + $this->num4) . 'i'; } } public function subtract() { if ($this->num3 + $this->num4 > 0) { echo $this->num1 - $this->num2 . "+" . ($this->num3 - $this->num4) . 'i'; } else { echo $this->num1 - $this->num2 . ($this->num3 - $this->num4) . 'i'; } } public function compare() { } } $cal = new Cal($_POST['num1'], $_POST['num2'], $_POST['num3'], $_POST['num4']); switch ($_POST['op']) { case 'j': $cal->plus(); break; case '-': $cal->subtract(); break; default: echo "参数错误"; break; }