先保存函数,再在函数头写/**+enter就行了
/** * @param $num1 * @param $num2 * @param $opt * @return float|int */ function calc($num1, $num2, $opt) { switch ($opt) { case '+': $res = $num1 + $num2; break; case '-': $res = $num1 - $num2; break; case '*': $res = $num1 * $num2; break; case '/': if ($num2 != 0) { $res = $num1 / $num2; } else { exit('除数不能为0'); } break; case '%': $res = $num1 % $num2; break; } return $res; } echo "\n"; echo calc(1, 2, '+'); echo "\n"; echo calc(1, 2, '/'); echo "\n"; echo calc(1, 2, '%');